Jump to content

rysalo4ka

Member
  • Posts

    8
  • Joined

  • Last visited

rysalo4ka's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Now are the classes in here is the hardest part since here i am a total NOOB and i am a little bit confused on how to represent the connections between friends, event and gift and event and users and which functions are needed <?php /*Models*/ class DB{} //will think of it later class user{ private $id; private $name; private $password; private $email; private $birthdate; private $picture; private $UserinEvents[]; // here we have an array of the class UserInEvent with all the relevant events to this user. private friends; //class friends //Functions function __construct(){} getters & setters function edit_user_details() function _user() } class friends{ private $id; //of the user that called this function function __construct(id){} function add_friend(); function delete_friend(); function show_friend(idOfTheUser); function show_all_friends() } class UserInEvent{ private $userID; private $eventID; private $roleID; } class event{ private $id; private $name; private $description; private $date; private $timeStart; private $timeEnd; private $place; private $eventType //myEvent or EventForSomeone private $gifts[]; //array of gift class private $userOwner[]; //class user. We can have as admin a person who created the event and others he made an admin function __construct(){} getters & setters function showAllGifts(){} function editEvent() function deleteGift() } class Gift{ private $name; private $link; private $description; private $picture; private $cost; private $wantLevel; // From 1-nice to have to 3-Heart desire private $chosen; //the gift is chosen by someone to buy it - then chosen=1. Not chosen=0. Partly chosen = 2 function __construct(){} getters & setters function editGift() } ?>
  2. So - here are my thoughts about system implementation. What do you think? First- the Views 1. Index.php - the main page view. We have explanation about the system and Login\Registration buttons. The buttons open a pop up window which allow them to register or to login to the system 2. UserPage.php - the main page for a register user. This page has: User picture and name and a link to edit user personal data. A list of all created events and an option to delete or edit them. An option to create event. A list of all the events that user was invited to. A list of all gifts that the user decided to buy for his friends with a delete\edit button A tab with his friends. 3. CreateEvent.php - here the user creates the event and adds gifts that he want. Each gift will be added in a pop-up button. Then you can choose which friends to add to the event. 4. EditEvent.php - i am not sure if it the same page as create, just with all the data inside or for simplicity a new page 5. Event I was invited to - the event page as the user that was invited to - sees it. He can see all the info of the event, choose to participate in a gift or to buy a whole gift. 6. Friends.php - a list with all my friends with an ability to add a friend or delete him. Second - the DB The tables that i thought i should have. I am not sure if i want 3NF or 2NF User table: all the user personal Data. PK: UserID Event table: all the event personal data. PK: eventID Gift table: all the gift personal data. PK: giftID GiftInEvent table: Gift Id and Event ID UserInEvent: UserId, EventId, UserRole (is it the owner or invited) Friends: UserID1 , UserID2 What do you think? Should i build it differently?
  3. The book i was regarding to - didnt spoke about MVC. Its just gave an example of how to make a View GUI in an OOP way.
  4. First, I want to thank you for your detailed explanation, it is indeed, very helpful! Couple of points, raised by your reply: 1. Why advancing in OOP causing to complicate the MVC pattern? I supposed that we have some level of complication which is the best and more of it will cause the program to be too complicated, not? 2. I want to confess that my own projects were written on notepad++. I still didn’t figure out why it is better to use a framework and what to choose, since there are so many of them. 3. I liked your template object and I will think of its implementation. I also felt that my user class it too big but I didn’t know how to make it smaller. Thanks for the advice. Do you have one template class to handle replies for all the views? Each controller is building its own template object and pass it to the view? I will try later to sketch a beginning for my program and will be happy for your comments regarding the classes. 5 So as I understand it: Model = php classes. You have a php file per class, right? Controllers are mainly functions that use the php classes, create objects and maintain the logic between what we show on the screen and what the user gave us as an input and the DB Regarding the views: I like your approach. It means all the logic is handled by classes (and then by the controller) and the view uses the output in an array or something else. Is there a reason why you prefer this way and not the way I saw in one of the books, where they build php classes that build a View (for example form class that echo a form, based on different parameters) And of course css and js are in different files.
  5. This is how my first ideas go about the classes but i know that its not for example an MVC approach and i dont know how to change it to MVC: class DB: connection and manipaltion to DB. field: con and all the operations with it are functions. class user: user can register, can unregister, add friends, add events, delete friends, delete events, add gifts, delete gifts, add friends to events, delete friends from events, paricipate in a gift, buy a gift. fields: all the user information, array for events. class event: we can create an event, add a gift to event, change event permissions, delete event, edit an event fields: event information an array for gifts class gift: create a gift, edit gift, delete gift, being chosen, send email to the gift buyer gift information (name, links, picture, cost) and also how to represent views? are they also classes?
  6. I am also trying to read now about design patterns. Should i have a pattern for each class? Or maybe its better begin implementing the classes and then see how i can improve it with some design pattern? and i still dont understand why is it better to write an interface and only then implement it in a class.
  7. First - thanks for the replies! I got laughed at in other forums i posted in, because i dared to say that doing it in non OOP way is not the best way in my opinion... Of course i dont use MYSQL. When i started learning PHP, i began already with MySQLI. Other questions: why is there a leaning towards PDO? the only difference i have found is the fact that PDO works with different DBs. but if i write my class in a correct way and later i will move to another DB, then i supposed to re-write only the DB class, right? I know about MVC and i used it in .NET, I dont know why, but it is very hard for me to understand the implementation in PHP. I supposed to have a model == class for each "major" table in DB, right? (user, event, gift and others) The controller is also a class? For each model? In the view - should i have some PHP? Is it supposed to be just an HTML+JS?
  8. Hi, I have some experience with PHP but i decided to move on to OOP (and design patterns). The idea is to read things that i find relative and try and implementing it in a system. I wanted something that will need OOP and can be something fun and i thought of an idea. The problem is that because of years of a mish-mash code where html + JS+PHP all together + control C and control V habits, i find it difficult to begin. I want to do it the "right way" and not middle way - to use design patterns where they are needed and do a correct PHP. Will be glad for tips about the beginning. My idea (the simple) I want to build a site where people can register and choose who are they friends (from other registered people) then a person can open an event (for example: birthday, wedding, baby shower) and under the event he can list presents he really wants. He can add links to specific items and pictures. His friends will see it and they can check out gifts that they want to buy the user that opened the event wont see who checked what but other guests will see it, so they wont buy the same gift also if a gift is expensive, people can partially check it with the amount of money they can give and when the amount is reached, an email will be send to all the pariticipants in the gift The reason for the idea is all those baby showers with the same gifts that people dont want or need to exchange, moving to new home parties where people really need small stuff but receive things they dont need and generally for people who want to buy an enjoyable gift but dont know what the person needs. The idea (complicated) Login with facebook different gift levels - really need, my wish, i will enjoy an ability to see what the person liked or got so even if he didnt open an event, you know what to give him different visibility levels - the person doesnt know who will buy what, the person knows what was checked out but not who did it, full visibility chat between guests so they can discuss the list and so on... For now i have questions, just to make sure i got this correct: 1. Design patterns are basically ideas of a correct class structure that is used for a specific problem. Each design pattern solves some problems. For example singleton pattern is basically an idea on how to create a DB class. 2. The problem that i am currently unable to find a solution for - is what is the correct way to implement GUI. I saw couple of ways: 1. The old html page with php embeded into it - this i want to avoid 2. Some people just gather all the information they need from the server and send this as jason and implement the GUI only on a client view- i am not sure why i dont like this idea, but i dont. 3. I saw an example of a class, called "form" that basically used a php class that echo all the html needed for a form - it is a very long way to implement something rather simple, and i am still not sure if this is the correct way 4. Something else? 3. What do you think of my idea, how to begin implement it? The main concern is to make something that i wont be able to make bigger in the future. 4. Mysqli VS PDO - i am using Mysql server and i am familiar with Mysqli. Is it really better to learn PDO or i can stick with the Mysqli library?
×
×
  • Create New...