Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abs and rel path #2

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open

Abs and rel path #2

wants to merge 25 commits into from

Conversation

mogyorosimartin
Copy link
Contributor

Features of the first 4 weeks and First Feature of week 5.

@hegyhati
Copy link
Member

hegyhati commented Dec 7, 2019

Elsokent takaritsatok ki ezt a sok szemet file-t.

Copy link

@wajzy wajzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Van itt baj. Pl.:
wajzy@lenovo:/Letöltések/SZE-MoSzE-2019-AC-DC$ ./bin.out
/
$ mkdir egy/ketto/harom
/$ ls
egy/ketto/harom
/
$ cd egy
ERROR: No directory with that names exists.
/~$
A kódotok nem tartja be az OO elveket, és nem hatékony. Utóbbi csak zavar, de az elsőt semmiképpen sem tudom elfogadni.

all: Project1/Source.o Project1/Folder.o
g++ -o bin.out Project1/Source.o Project1/Folder.o

Source.o: Project1/Source.cpp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, ebbe a sorba nem kellene felvenni a Folder.h-t is?


}
bool parametercheck(vector<string> command, int parameternm =1)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nekem úgy tűnik, ez a függvény ekvivalens ezzel:
return command.size() > parameternm;
De valóban egy függvény adja a leghatékonyabb megoldást ennek a kérdésnek az eldöntésére?

tempFolder.AbsolutePath.push_back(name);
return tempFolder;
}
vector<string> Folder::split(string input, char charsplit)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A függvényetek működik, de

  1. valójában ez lehetne statikus, vagy akár osztályokon kívül definiált függvény, mert semmit nem használ az objektum adattagjaiból.

  2. Lehet ezt egyszerűbben is, pl.
    vector split (const string &s, char delim) {
    vector result;
    stringstream ss (s);
    string item;

    while (getline (ss, item, delim)) {
    result.push_back (item);
    }

    return result;
    }

Nem én vagyok ennyire okos, itt találtam egy guglizás után: https://stackoverflow.com/questions/14265581/parse-split-a-string-in-c-using-string-delimiter-standard-c

if (tree[i].AbsolutePath == tempvector)
{
return tempvector;
error = false;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Erre a sorra mikor kerül a végrehajtás?

}

}
if (error)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detto, magának az error változónak sincs így értelme: ha nincs hiba, akkor úgyis visszatérünk már korábban return-nel, ha meg nem térünk vissza, akkor az error garantáltan true marad, nincs mit ellenőrizni rajta.

#include "Folder.h"



bool Folder::dirnamecheck(vector<Folder> tree, vector<string> currentpath, string name)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha jól látom, ez a függvény sem használja az objektum egyetlen változóját sem.

string parentfolder;
string type;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ez az a típus, ami lehet file értékű? Túl azon, hogy a string típus egyszerűen túl "sok" ide, meglehetősen félrevezető a névadás.

string name;
vector<string> AbsolutePath;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miért kell minden mappáról külön eltárolni az összes szülőjét? Miért nem elég a szülő mappát tárolni, akitől meg lehet kérdezni az ő szülőjét, és így tovább, vissza egészen a gyökérig? Nagyon memóriapazarló és lassú adatszerkezetnek tűnik nekem ez. Ha ellenőrizni akarom egy fájlbejegyzés létezését, akkor az összes létező bejegyzést egyesével végig kell majd nézegetnem, ahelyett, hogy kihasználnám a fa tulajdonságait, és egyre kevesebb elemből álló részfákat kellene csak átbogarászni.

public:
bool dirnamecheck(vector<Folder> tree, vector<string> currentpath, string name);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tehát ha jól értem, akkor itt minden adattag nyilvános. Hogyan valósul meg így az adatrejtés OO elve?

}
return true;
}
Folder Folder::mk(vector<Folder> tree, vector<string> currentpath, string name, string type )
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Akkor jól értem, hogy ez van konstruktor helyett? Mi indokolja ezt a szokatlan megoldást?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants