Bir kullanıcı sınıfı, iyi bir yaklaşım?

0 Cevap php

Ben genel bir kullanıcı oluşturma, silme ve değişiklik yönetmek bir kullanıcı sınıfını inşa ediyorum. Benim sınıf bu şekilde kullanılmalıdır:

# creation
user::create($username, $password, $email); // Does not need of $id

# modification
$u = new user($id);
$u->edit('password', $new_password);

# deletion
$u->delete();

Basically the class contain a static method create() that obliviously does not require the used id as argument. After the creation you can gather user infos and manage the user creating an instance of the class user and set as argument the $id of the user. Is that a good design or should i create something like:

# creation
$users = new genericUserMethod();
$users->create($username, $password, $email);

# modification
$u = new specificUser($id);
$u->edit('password', $new_password);

# deletion
$u->delete();

... 2 farklı sınıfları oluşturma. Ya da başka bir yolu var mı?

0 Cevap