N
N
nickXoo2016-08-10 20:01:52
Programming
nickXoo, 2016-08-10 20:01:52

Are there simple examples of using OOP?

Hello.
Where can I find examples of using all the principles of OOP in a real program, so that a beginner can understand. Googled it. Yes, it is clear that there is a dog class that has characteristics and functions, on the basis of which Bobik, Sharik and Tuzik objects are created, which can also have additional characteristics. But it was not possible to find a practical example.
Maybe someone has their own experience or links? I will be grateful.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
G
GavriKos, 2016-08-10
@GavriKos

Any source code of any UI thread. There is usually some kind of IDrawable, from which Button is already implemented, from which ToggleButton, etc. For example, you can see the class hierarchy for the android UI.

D
Dmitry Alexandrov, 2016-08-10
@jamakasi666

"Design Patterns" O'Reilly . Masterpiece examples, written in simple language, heaps of examples and excellent explanations of what\why\why.

D
Dimonchik, 2016-08-10
@dimonchik2013

Scrapy
Django

I
index0h, 2016-08-10
@index0h

The simplest example: a logger. All it does is pass the date and message to N places: console, file, queue, udp,...
It can be implemented stupidly: write N similar loggers for each transport. You will have to manually ensure that the interface of each is identical. For many languages, changing from one logger to another will not be easy.
Option B: an abstract logger and a bunch of separate extensions. It has the right to life, but this is a dead end thing from the point of view of further development. From the logger, in addition to sending data, it is often required: filtering, aggregation, routing, different reactions to different levels of messages, etc.
Option B: use the adapter template. Implementation for each transport with a common interface for all. In this case, you will interact with the adapter, not the implementations. Routing is implemented (depending on complexity) either in a separate class or as part of an adapter, filtering is the same, and so on. This is your main benefit - the independence of different parts of the system.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question