Answer the question
In order to leave comments, you need to log in
How to adopt object-oriented thinking?
Hello masters.
Here I ran into the problem of understanding object thinking. Those. It's hard to understand what to "shove" into one object, what into another, what should be a static method, what should be private, and so on. In general, writing all the time on the procedural, it is difficult to switch to oop.
And now I want to gain experience and knowledge in writing OOP. Tell me which project to start writing (guestbook, blog), or maybe start learning the framework.
Or maybe tell me a book / site where a project is written step by step in OOP, so that understanding comes faster.
Thanks in advance for your replies ;_
Answer the question
In order to leave comments, you need to log in
Those. It's hard to understand what to "shove" into one object, what into another, what should be a static method, what should be private, and so on.
Browse at your leisure HeadFirst Design Patterns :
www.combook.ru/product/10741424 + as mentioned above,
Matt
Zandstra PHP : Objects, Patterns and Programming Techniques :
www.combook.ru/product/11140344 reference point
Very simple.
To begin with, admit to yourself that procedural programming also suffers for you (otherwise you would not have this question), it's not scary, but something needs to be addressed with this too.
Take any of your procedural projects (preferably a small one so as not to get stuck in a routine).
Step one - everything is a function, so you put all the code outside the functions in functions, in total you get that outside the functions there is only a call to main () (or whatever you call it)
The second step - functions work only with what was passed to them. Delete global variables.
The problem of deep nesting appears, i.e. you have B inside call A, and B in it, which wants a variable from A's scope, and there are many such cases. To drag all these variables into B is sad and sad, so we do a trick, each function receives an array of some values as the first argument. There is only one rule - functions do not change the names and number of variables in the array, only the values.
The third step - functions should be short, take out repetitive code in separate functions, if a lot of variables are used in a function - this is a reason to break it into several smaller ones.
The fourth step - you are already writing in OOP. If 3 steps are done correctly, then it remains only to arrange this matter according to the new rules - the first array argument is class members, respectively, functions using the same array - methods of this class, you will have to deal with access to fields and individual dependencies, but this will already be simple and understand when you get there.
Take OOP docks and some framework and spend 48 hours on them. Not 2, but 48. And everything will become clear. Your problem is very common after the 2nd hour of dating.
It will be difficult, you will want to drink, spit and enter the Belarusian random, but you have to endure. It will take 48 hours and everything will fall into place.
If you plan to stew in your own juice, then be prepared for the fact that a task that another person spends a month on can take you five years.
Don't be lazy to read good code. Try to start with symfony.
Honestly? Only two books. At least diagonally.
Expansion of consciousness is guaranteed.
Tell me which project to start writing (guestbook, blog), or maybe start learning the framework.And so and so it is possible, and ideally even necessary, in the framework you will learn more about using OOP, and in your project - designing OOP if you think about how to optimize each of the tasks using OOP, and also gain experience from frameworks .
Or maybe tell me a book / site where a project is written step by step in OOP, so that understanding comes faster.No one will do such an analysis for free, and the majority cannot, therefore, themselves.
Psychologists "objective thinking" this is called abstract thinking. Abstract thinking distinguishes Homo sapiens from other living beings. OOP was invented to simplify writing code, the programmer describes the task in images (objects), i.e. as it is. In short, if a programmer is a person, then he doesn’t need to go anywhere, if not a person, then he is unable to write programs
Dmitry Eliseev
www.elisdn.ru/oop-week
Very chewy and explains clearly.
There are many free videos to understand the level.
This is not another shit-course on how to cut money on retelling the documentation.
Check out the blog posts. I really didn’t take the courses, but I watched the video materials.
Play JavaRush Explained
quite clearly using the game as an example. At the same time, you can learn Java if you wish.
Hello, I myself started learning PHP from scratch two months ago, I have already read something and learned about OOP. Look at this course, maybe it will become a little clearer...
https://www.youtube.com/playlist?list=PLSdH7dYnlGY...
And most importantly, do not stop at any difficulties, but take them as a challenge.
Try programming in Smalltalk. I do not write "learn" - it is better to learn Smalltalk in practice, preferably on a more or less real project.
Today, perhaps, the most "advanced" implementation is Pharo.
First questions can be asked in the Russian Smalltalk User Group
book - hail butch
upon the fact of study - look at the real world. everything is an object. one object can be shove into another, connect them somehow, there are interfaces for the interaction of objects
, everything is elementary
GRASP
Base Craig Larman - Applying UML 2.0 and Design Patterns. 3rd edition
Brett McLaughlin - Object Oriented Analysis and
SOLID Design in PHP https://www.youtube.com/playlist?list=PLoonZ8wII66...
Martin Fowler - Refactoring. Improving existing code
R. Martin - Clean code. Building, Analyzing, and Refactoring - 2013
Steve McConnell - Code Perfect 2nd Edition
Advanced
GoF Erich Gamma, Richard Helm - Object Oriented Design Techniques. Design Patterns
Martin Fowler - Patterns of Enterprise Application Architecture
Andrey Bibichev - Domain-Driven Design
Carlos Buenos Vinos - Domain-Driven Design in PHP – 2016
Microsoft Application Architecture Design Guide
Vaughn Vernon - Implementing Domain-Driven Design Methods
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question