What are the practical advantages of using object orientation in the day-to-day life of a development team?

Asked

Viewed 4,453 times

25

Work in a company that does not use object orientation, although the language allows (and encourage).

I have studied and study object orientation, and do my personal projects in OO, but I do not know exactly what arguments could be used to motivate a company (which is in a comfort zone, from the technical point of view) to consider developing new projects in an object-oriented way.

Anyway, if I went to talk to my manager, what would be the most convincing arguments in favor of object orientation?

  • 8

    If the question was the other way around, I would answer :) Although OOP, if you look for my answers, you will see that I am critical of the paradigm. At least to his abuse. This website built in language sold as being OO but avoid the paradigm as much as it gives and get better results because of this. There’s a lot of people who think O shows when it’s not true. Many programmers think that using classes is doing OOP, which is far from true. So don’t let him see what I have to say :)

  • 9

    Just my opinion, but if O is not needed so far, maybe the ideal is not to use it even... On the other hand, if you can identify anti-patterns in the codes (e.g., excess of if..LSE that could be best expressed via polymorphism, functions with "strange" names to "help remember" which type they apply to, etc.), then these problems themselves should be used as an argument for change. By the way, I miss functional programming much more when it is not available than OOP...

  • 1

    @Arthurdeandrade, just out of curiosity, what language is used?

  • @Fernando We have projects in C#, Delphi and PHP. The main and first tool of the same company is Delphi, now newer projects are already being done in other languages like C# and PHP.

  • 2

    Seeing the responses received (including mine), I imagine you might be thinking, "okay, and now how do I explain that for my manager?..." P

  • 1

    It’s @mgibsonbr. I was posting a comment to you at this point when I asked myself this question too. In fact, although complete, both answers do not present strategic arguments that contribute such a great culture change. I think at this point, my unfortunate response was the one that came the closest. After all, all my positions affect a company strategically.

  • 3

    @andradedearthur Don’t talk to management in "Object Orientation" - talk about the problems of current code and the benefits of "improving software engineering" of the company. The benefits you find in the 3 responses posted so far, including the controversial response of Joãoluizgrigoletti, which, although incomplete, is correct. From what I have seen, prefer procedural in a language that supports very well the most useful paradigms of OO is lack or knowledge of OO (real OO and not the academic one of decades ago) or lack of experience with procedural codes in these languages.

Show 2 more comments

4 answers

23


Standardization

Just as a child who is learning to read has difficulty joining the letters to form words, an earlier one already reads whole words but strives to join them in sentences, and a proficient reader already "sees" whole sentences, so does programming. If you saw a noose for If you go through a list every 1 million times, you don’t get lost in the syntax of that specific instruction, your look already falls into the particular details. Similarly, if you’ve seen N online examples of a task being done in a certain way in the X language, seeing a similar code already becomes its second nature.

If a language works predominantly with OO practices, adopting these same practices in its code makes it more readable than not adopting them. Not because OO is more readable than procedural, functional, etc., but because professionals with experience in that language are already conditioned to think that way. If a project is being made from scratch, by professionals who are not foreign to syntax and OO semantics, developing it in the most "usual" way to the platform contributes to its maintainability, especially if a group of professionals other than the one who wrote it may possibly be responsible for supporting it.

Flexibility in the workflow

A strictly object-oriented program has neither a "start" nor an "end": instead, it has a set of objects capable of exchanging messages with each other. The order in which these messages are exchanged matters, of course, as well as it is possible to save even global state using objects. But changing the order in which certain subroutines are invoked is something (at least in theory) more feasible in an OO architecture than in a procedural one - because it doesn’t necessarily involve restructuring the entire code.

Explaining this better (because my last statement is dubious), in a system where operation A always occurs before B, one can assume certain things about its state at the time B is executed. If you decide to pass B to before A, it is necessary to make an assessment of all that was assumed to be true in B and verify what is still true and what is no longer true - and therefore needs to be adapted.

Object orientation does not "magically" solve this problem, but it does help modularize the decision process: by establishing (formally or informally) that object X has certain invariants, and only programming assuming such invariants as true, avoid falling into the addiction of writing code that "only works if A, B and C has already happened". Instead the OO forces you to evaluate whether the state of the objects involved in certain computation are able to perform this computation, regardless of the sequence of events that brought them to that state.

Switching in kids, it is easier to create a script (in the sense of "script") to put order in a system that allows N actions than to divide in N actions a system expressed by means of a script...

Levels of abstraction

Ideally, we should always program at the right abstraction level to represent the problem we’re dealing with. That’s why no one "programs a game", for example: a program engine games, and uses the scripting language of that engine to create the particular game. This can be done even if you do not intend to reuse this code in any other game.

Some recommend using Dsls ("Domain-Specific Languages") to achieve this goal, but in general this is very impractical - it’s not easy to learn a new language, or at least it’s not easy to "get the hang of it" quickly how to do the X action in the new Y language. A more common language is preferable, but it makes no sense to limit itself to the basic primitives of this language to develop at the higher levels of abstraction.

It is at this time that the use of types defined by the user is interesting: the concept of "object" may not be exactly the same concept of "type", but they have a lot in common (and a "class" can be used to represent a "type"). By uniting data structure and functionality into a single unit, and combining the basic operations of that unit to perform complex computations (as opposed to doing it using the basic operations of its components), you are reasoning at a higher level, more appropriate for the problem to be solved.

Reiterating: custom types are not the privilege of the OO paradigm, but are one of the benefits of using this paradigm. If you encapsulate the numerical components of a matrix or vector it is not "for any careless programmer to tamper with them by mistake" - but rather to enable you to express your computation as a series of operations on vectors/matrices instead of expressing-It was like a series of scalar operations. If you evaluate that your system would benefit from a greater wealth of types (great "if" - I personally am of the opinion that there are many cases where a basic structure is more appropriate, and that the use of classes is Overkill), may be an argument in favor of adopting this particular OO resource (with or without inheritance and polymorphism).

Extensibility

Sometimes it is necessary for a system to be extensible, especially when it is necessary to support different data formats and/or interface with third-party systems. In some cases this can be done in a purely functional way (i.e. a dictionary mapping a name to the function that deals with that name), but in others a set of distinct but related operations may be required (and perhaps still retaining state) to accomplish a certain task.

In this case the use of an abstract/interface class specifying what needs to be done, along with N concrete classes performing What has been specified seems to me to be a very appropriate way of dealing with that scenario. Other paradigms (e.g., logic programming) may also have adequate means, but if their options are "objects" and "chains of ifs, "I would say that you have a good argument at hand in defense of the use of inheritance and polymorphism.

  • 4

    Note: I never stopped to think in detail about what it means to "be object oriented" vs. simply "support objects", so I gave my answer simply by enumerating reasons why the encoding style OO and/or certain characteristics OO could be desirable given the circumstances. But I am open to criticism if for example I have made misuse of the concepts involved.

  • 5

    Poxa, fantastic explanation about the sequence of events, the states and the assumptions. Here’s another interesting argument: understanding O is a good initial step to later learn and explore other paradigms, such as Service-Oriented and Agent-Oriented (in the latter, where entities are not even required to respond to a received message - an "assumption" still strongly existing in OO). :)

  • First, I would like to apologize for my misunderstanding in my comments. I would also like to congratulate you on your reply. Simple, concise and complete. I was somewhat silent, by not removing from the term "macaroni code", the well written, procedural programming.

  • @Joãoluizgrigoletti No problem! : ) I noticed your misconception, in fact my comment had two purposes: 1) give my opinion on your reply, of course; and 2) break the cycle of comments between you and the bigown, which was not only extending beyond healthy but was falling apart on the personal side... I agree with a lot in his reply (so I did not give -1) but I also disagree with a lot (so I did not give +1), and apparently the others also abstained from voting on it. In particular, I agree when you say that "[your] response was the one that came closest"...

  • ...something of interest from a managerial point of view, although I found its conclusions misleading. Explicitly: "fallacious" is different from "wrong", a fallacious statement may be true even if the logical arguments that led to it are invalid.

  • 2

    Reading your answer to me is clear that between Delphi/C# (AP languages) OO and Delphi/C# procedural, OO has only advantages. What would be the advantage of doing procedural instead of OO in these languages? Your answer is an ode to OO but you say by the comments here and there that there is another side and does not explain which other side is this. Opt for procedural instead of OO in these languages is a symptom of not knowing OO and in practice it does work in macaroni code. Knowing well OO, I myself can prove that procedural is possible without noodles, but it is not what happens in practice.

  • @Caffé In this answer I only presented arguments in favour of the OO, not as an "ode", but rather to highlight where the OO has strengths and when these strengths are an advantage. I agree that opt for A instead of B in general is bad, no matter which are A and B - the ideal is always to use the best tool available (as long as it is available). As for this "other side" that you say I talked about, I’m not sure what you refer to (I would need to reread my old comments), it would be the fact that there are alternatives to OO, or it would be a statement that OO also has weaknesses?

  • @mgibsonbr His demonstration of OO’s advantages over procedural was so effective that it unwittingly became an ode - that’s what I meant. You have demonstrated that in languages with broad OO support, it is the case to use OO instead of procedural. When you see code using little object orientation in Delphi and C#, this code is rather macarronic. In practice, in the absence of using objects (doing everything procedural) too wide scopes, high coupling, strong dependence on a certain sequence of steps and zero reuse are used. But I understand you’re more thoughtful than I am :)

  • @The problem is that there is a false dichotomy: procedural vs. OO, and nothing else. This ignores all other possibilities (functional, logic, dataflow, etc.). But mostly ignores the imperative vs. declarative question: I often find myself not only avoiding the creation/use of unnecessary classes, as has already occurred (in a recent project, including) of me writing a code to turn declarative into OO because the system demanded OO. It’s hard to explain in words, but look that Python/Django code, where I avoided creating 13 useless classes just because...

  • ..."the framework required". If you don’t understand the code, then I can explain it better, preferably in chat. P.S. This code in the Pastebin will self-destruct in 24h :P

  • @mgibsonbr In fact where I engaged was in the procedural vs. OO in languages with broad OO support, which is a common debate in the cited languages. Although other paradigms are available, when you haven’t even learned to "form words", the conversation is restricted. I’ll look at the code, thank you.

Show 6 more comments

16

I begin with the following definition of Paradigm, extracted from Wikipedia:

Paradigm (from the late Latin paradigm, from the Greek παράδειγμα, derived from παραδείκνυμι «show, present, confront») is a concept of sciences and epistemology (the theory of knowledge) which defines a typical example or model of something. It is the representation of a pattern to be followed. It is a philosophical assumption, matrix, ie a theory, a knowledge that originates the study of a scientific field; a scientific achievement with methods and values that are designed as model; an initial reference as a model basis for studies and research.

It sounds like a super complex definition, but it’s not. Basically a paradigm is a suggestion to approach something, a way of thinking. In our case, as system developers, it is a suggested approach to problem solving through computational automation. I started by this definition because it is easy to forget that there is the letter "P" there in the acronym "OOP" that does not necessarily mean "Programming". When I started studying the subject, it was much more common to translate "OOP" as "Object-Oriented Paradigm". Which, let’s face it, makes a lot more sense, since programming is just the act of building - planning the solution of problems goes way beyond that.

My main reason for using (and indicating) an "object-oriented way of thinking" comes from the nailed approach (read: "of the way of thinking").

The structured paradigm is intimately directed to the resolution of a problem through the routing of the solution. That is, when programming, basically it describes step by step what needs to be done for the problem to be gradually solved. This approach is very natural because the computer is much better than we humans in executing precise instructions very quickly. And that’s just it the definition algorithm:

An algorithm is a finite sequence of well-defined instructions and not ambiguous, each of which can be performed mechanically in a finite time period and with a finite amount of effort.

This way of thinking is enough to solve various problems since they can be scripted, and in fact has been used since the first computers were created (either using valves or punched cards). It turns out that as the complexity of the problems to be dealt with grew, the scripts became larger and more difficult to read and understand (by us humans). It must be easy to imagine how hard it is to interpret the function of a sequence of instructions (arithmetic operations on variables, for example) in the middle of a really extensive program (and perhaps devoid of local comments). :)

Incidentally, it is not surprising that many structured languages provide the possibility of creating functions. Maybe you haven’t thought about it until then, but the semantic meaning of the word is this: a function does something important, that is, it has some role (a function! hehehe) in the global resolution of the problem, in an atomic and reusable form. This division into functions allows not only organizing problem routing in a way that is humanly understandable (because for the computer it is all jumps to even memory addresses)but by itself already brings numerous advantages such as reuse of code and ease of maintenance (arguments that are commonly used to qualify OOP, but that do not actually depend on this paradigm).

What OOP is, in fact, is an evolution in the way of thinking the solution to a problem. There is a consideration at a slightly higher level than just the functional character of solving small aspects of a larger problem. There is also the representation of the entities involved. In another issue on the origin of OOP one can observe that there are various inspirations for this way of thinking, and note that the main need is related to understand also:

  1. Which entities are involved in the problem area
  2. What are the relations between these entities

Entities can be called many forms (classes, frames, it doesn’t matter), but they represent something relevant to the problem and they group (and clearly identify) not only the functions (or methods, or behaviors) but also the data (or attributes, or slots) that are manipulated and necessary for the problem to be actually dealt with.

It should be easy to see that this is a way of thinking that, at its core, is independent of a programming language. You can construct the equivalent of classes in C language using structures with regular variables to serve as attributes and function pointers to serve as methods. And new structures can have pointers to existing structures as a way to simulate inheritance. What many modern languages do is simply facilitate the use of this paradigm, as has already been well put by colleagues in comments. But even if you use C++, C# or Java, there is still in the methods the necessary routing for the resolution of the component parts of the larger solution to happen. Because remember, computers do just that: execute instructions very quickly.

And the advantages?

Having discussed all this (sorry if it was too long - I just tried to be didactic), the main advantage of this way of thinking (i.e., of the object-oriented paradigm) that I see is in the organization of work. As one starts thinking about the entities involved, their roles in the general resolution of the problem and the relationship they have with each other (and that also help in the solution of the problem), it is much easier to build the solution gradually. You see, complex problems have a difficult understanding, and it’s common to notice certain nuances throughout development. An object-oriented design organization facilitates the evolution of the code (in certain cases, just inherit a class - and here I think it is advantageous for you to read regarding the discussion of multiple ifs, which was also mentioned in comment).

It also facilitates maintenance as it is easier for a human to remember the entities involved in solving the problem than their individual behaviors. Imagine that you need to maintain a project of your own, but after many years. If there is an issue related to order printing, it should be easier for you to simply spend your time analyzing code from the Request class than to seek to understand and find related functions in the middle of several code files.

P.S.: Note how anyone who argued that simply organizing functions into closely related files would be, in a sense, using this paradigm unknowingly! hehehe

But remember that not everything is an advantage. As also mentioned in comments, a team that has not studied and does not know the paradigm can spend valuable time learning. The experience (and the large number of questions here at SOPT) indicate that there is a beautiful learning curve involved. In addition, for critical applications where running speed and/or memory usage are important non-functional requirements, the additional computational effort stemming from the facilities provided by OO resources (such as overloading methods and operators, or copying builders) may bring relevant disadvantages.

  • 3

    Great answer. I agree: you make a great OO code and a professional who does not understand OO will not be able to maintain it. But the reverse is also true: you make a macaroni code (and I have seen that the absence of OO in Delphi/C# is always macaroni) and only you, with luck, will be able to maintain it. So while there’s the cost of the OO learning curve, on the other side there’s also the cost of the code’s own learning curve. From what I’ve observed, the cost of the second is much higher, and it’s easier to find someone who understands O than someone who understands your bad code.

6

Usually, if you try to defend object orientation in a company that doesn’t put it as a basic premise, the first thing you’ll hear is: -For what? does not work fuinciona? In team that is winning we do not touch.

Actually, the noodle code has its advantages. It’s easy to do, it’s very fast to develop, and usually, programs that go into production using this "architecture" run frighteningly faster than their puffy cousins.

For you to get a macaroni code that you made is one thing. Another completely different is to put this software in the hands of a new developer. The guy will go crazy. Another problem arises when someone wants to improve this software. That old story...my software sells apples. But now I want to sell grape...

Clarifying the context let’s go to my justifications.

  • Dependency of Professionals - Whoever understands a macaroni code is only its creator. If another professional gets his hands on it, he’ll probably spend months deciphering what the other developer did. This creates a dependency relationship between the company and the system developer. This professional becomes more expensive every day, after all the system can not stop and it is not easy to find someone who can continue the project. The subject becomes virtually irreplaceable, which is not good for the company.

  • Maintenance and Evolution - As I said before, the software is to sell apples and not grapes. Then starts the gambiarras. You look at the code and you start to find a lot of "flags" and a lot of "if’s" like: if(Uva)...in a little while the software doesn’t handle maintenance anymore. Then they go crazy and rewrite all the code, because it’s quick to do without design standards. The cycle continues and the creator of the software one of these hours is earning a thousand dollars more. And everyone thinks he’s the guy, because nobody’s been able to touch the software. Another important factor is change management. How to manage changes in a software where probably not even the programmer can say what the ramifications of that change?

  • Side effects of evolution - Have you noticed that by changing a functionality in software developed outside of OOP standards there are always unexpected errors in other areas of the software? Of course, after all that field you had to remove from CRUD affects another 300,000 areas of the software. These side effects directly damage the company’s business, generating losses.

So the practical advantages in my opinion are:

  • OO code is easy to understand.
  • An OO project can be easily developed by a team, which does not occur with the macaroni code.
  • With OO code it is easy to find professionals who can continue projects
  • Allows company employees to take vacations
  • They ensure better maintenance and system evolution, since they use "small blocks of functionalities"
  • They are less susceptible to side effects, as dependencies are mapped more clearly.

And mainly,

  • It ends with the newness of programmers.
  • 5

    Interestingly I can’t understand the "lasagna" codes I see today. Nor do I understand unreadable codes, in any paradigm, mainly made because who does not understand all concepts of software development. Using OOP doesn’t solve any problems you cite. Doing right in any paradigm does. So I didn’t see a foundation in your answer that shows OOP should be used. Note that I use the paradigm when necessary. And procedural or OOP, my experience is the opposite of yours.

  • 1

    I agree that does not solve. If your style is the procedural as was mine a few years ago, and if you organize your code it is okay. The problem is that today, most languages are object-oriented. What does not give is the subject trying to make an almost procedural programming on top of a OO language.

  • Regarding Cobol, have you ever picked up a software developed by someone else on Obol? I’ve had a lot of problems with that in my life. Most of the software that my father left for me to take care of after he passed away was in Rio de Janeiro. My father was an organized guy. But it was very difficult to understand what he had done. Already the codes left in C++ were much faster, thanks to the segmentation of the code in small parts. Thanks to OO

  • Almost no language is object-oriented. Most allow you to use these paradigms if you want. Some make it easier, others not so much, and worse, some do it so dirty that it’s better not to use it. " Everyone "program, I’ll kick some, 80% of the time procedural in languages you call OO. Some can even do this a little less. But what they do much less often produce codes that are not understood by other people without much greater documentation than is needed when it is more procedural.

  • As I said before, I’ve picked up poorly written programs in several languages both in procedural and OO. Have you ever been to a Trabant? This does not mean that a car is a bad means of transport. I know great codes written in COBOL and some of the hardest-to-understand codes I’ve seen have been in C++ using plenty of OO. Have you looked at your old codes? Mine were terrible. I improved over time. I improved more when I learned other languages. I’ve learned to understand where the problem is. And it’s not the paradigm.

  • I have to disagree with you. Most of today’s languages (with the exception of PHP and a few others) are really object-oriented. And the problem, as you mentioned, is that 80 percent of people still try to program procedural. That’s not cool. I am not critical of procedural programming, quite the contrary. Today, I have developed much more procedural than OO, after all I am working with microcontrollers. Now I criticize using an OO language to program procedure.

  • The problem in my opinion is exactly the fact that they release you from the standards. What did not happen for example in Smalltalk

  • Like I told you, I don’t blame the paradigm, I blame the gambit of trying to follow one paradigm over another.

  • 5

    I think you don’t understand well the paradigms and how languages are constituted. Your information is incorrect. Really object oriented only has one language and almost nobody uses it. With OO features has several. If you don’t look at marketing and look at the literature on the subject you’ll see that successful languages are hybrid. And I think you have a noise in thinking that if language allows O people should just use this. They give freedom because this is advantageous. Experienced programmers are not purists, purism does not solve problems.

  • 4

    Although I agree with the ideas behind your answer, I am seeing a false dichotomy here: programming is not divided into "macarronic" and "object-oriented" - there are many other ways of programming. Even restricted to the imperative paradigm, the way to modularize the system, the constructions accepted or not, etc., have a great impact on these important non-functional characteristics that you mention. And as for "reliance on professionals," you’re right, this is a topic not to be underestimated. On the other hand, overdo the dose and you fall into the "lowest common denominator situation"...

  • 3

    @Joãoluizgrigoletti Are you responding to me or the bigown? My last comment was not to impose anything, I’m just pointing out what I saw. First you listed a number of important non-functional features, and I agreed with all of them. Then you attributed the negative characteristics to procedural programming, and the positive ones to object-oriented programming, and that’s where I disagreed. Now, if you have good arguments to support your claim that OOP has these good features intrinsically, and procedural no, that’s another story...

  • 3

    @mgibsonbr, first of all I apologize, my comment was not for you. I agree that there are only these two divisions. But I think in object-oriented language you should program object-oriented. As I said above, I program a lot in C. I have programmed a lot in Verilog as well and none of them are object oriented. Honestly, this talk of no object-oriented language is outdated. Paradigms change. What I meant by macaroni code is that in the current context, with modern and object-oriented languages it makes no sense to program procedural

  • 1

    ...in those languages, since they’re not meant to be. If you want to do this, use one of the thousands of wonderful languages that use this paradigm on the market. Or use one that allows for paradigm flexibility, like php

  • 5

    And honestly, after reading my answer, I noticed that I actually attribute the macaroni programming to the procedural paradigm. Mine Failure. I take a public view of that.

  • @Maniero a long time later, but I’m reading the advantages of Program OO, in a comment you speak " _italic_Really object oriented has only one language and almost nobody uses it. With OO features has several.Italic" What would be this language 'really' OO?

  • @Luizaugusto Smalltalk, and even this one there are questions, there is already understanding that it is oriented to messages and not objects :)

Show 11 more comments

2

This could be a further question for the Workplace than technical. Whenever it involves convincing management we may come across several barriers that go beyond the code or system itself.

Imagining that we will not have these barriers, say, policies within your company that can prevent this, and that the company could allow a more "abrupt" change in a new project or existing project (besides OO, it could be a new language, framework, etc), that your colleagues are also aligned with your thinking, then we can go to the main point of this discussion.

I will try to argue in a less technical way, because you need to align your speech according to your interlocutor. If he argues very technically, he may not understand.

And, finally, I won’t get into the merits of whether or not it’s better than very common procedural approaches like Transaction Script.

The difficulty of putting it into practice

Although the subject of object orientation is always in the "mouth of the people", experience shows that it is not simple to implement it in practice.

If you look at the subject reference books, you will often come across very simple examples, or ones that start from questionable premises (example: using a bank entity as an object) or complex ones (DDD in general).

That is, when we are thinking only of the organization of objects to meet a problem, everything looks beautiful: I create an object Ordem, who receives a Pagamento, that can be done with Cartao, etc..

But when we start talking about Apis entering data, saving information in the bank, validations, transactions, integrations, queues, retentatives, etc., things start to get very challenging and other approaches become more seductive. And this is what we didn’t even get to the challenge of composing the objects correctly (I get there).

So the ideal is to start with a problem simple and isolated. This would be the ideal scenario to propose this to your boss. Preferably, it could be embedded in a new system separate from the others. It is inevitable that there will be a huge learning curve if you haven’t worked professionally with object orientation yet, so this would be a good space to make mistakes and redo some things without affecting what already exists.

But why OOP?

Someone will ask.

Here it will be inevitable to compare the model that works (or "works") with your object proposal.

The most common argument here is to "hit" the current pattern: it’s confusing, disorganized, no pattern, scattered rules, etc. Depending on how the current pattern was implemented, this may help the discussion, but it may not necessarily be true to the standard. Maybe the confusing code in the current pattern is only there because the people who participated in the development don’t want/might/know how to improve.

So I would try to bring the advantages by avoiding the comparisons a little.

Advantage 1: proximity of business

An object organization allows the conversation between business people (Analysts, Pos, etc) and developers to get much more transparent. When speaking that the Pedido gets a Pagamento, this will actually be occurring in the code:

pedido.adicionarPagamento(cartao);

With the team’s effort in trying to use the same business language to model objects (known as ubiquitous language).

If your analyst/PO has some technical baggage, it can even help you with some code decisions if you know how to direct it in your understanding of it.

In other solutions you will see something quite different: maybe a DTO, service classes, validation classes, a repository, mapper, etc. Something more distant from the "reality" of business.

Advantage 2: Code becomes more self-explanatory

Another advantage that I see is that it limits a little the "evil creativity" of developers when organizing the application. As the searchlight of the application are the objects, you will always have a good notion of where to implement a new Feature or make a correction. For example, if you have any validation on the card part, you will search for objects related to Cartao.

This also leads to a natural movement of organize your system by packages according to business and not by Pattern.

However, in other solutions, this rule may be in some service class, validation class, entity, etc.: Is it in the CartaoService? RegistrarCartaoService? CartaoValidation? ProcessarPagamentoCartaoValidation?. Anyway, you can use other class names that you think have more meaning, but with the growth of system code this tends to quickly become a problem without a more rigid and clear control for class names and package organization.

Advantage 3: there are simple approaches to applying OOP

You don’t need to rely on dense DDD books to create a robust object-oriented application. There are approaches today, such as the Elegant Objects, which allow the use of object orientation without having to completely isolate its objects, requiring less code "infra" to save information or perform integrations. However, violating some principles considered "sacred". It also brings some welcome practices to the code, such as avoiding null. But it’s not a recommendation, because he has some views polemical. It’s just an example.

I could think of others yet, but I believe this is a good start.

Show me the code!

Often, it is necessary to literally draw so that people can understand your idea, what you are offering or saying. This is perfectly normal, some people are more visual. In the world of programming this can be achieved with a functional implementation.

Choose some simpler project functionality that already exists, and implement it using OOP. This will allow a comparison between the current model and the object-oriented model you want to propose.

And if he refuses?

You can have the best arguments in the world and not be able to convince your boss. Sometimes, it’s not what you say, but how you say it. Or there may be situations that run away from even his control that prevent this and that he can’t tell you.

Finally, ask him to explain the reason for the refusal if possible and, depending on his answer, ask him what he would need to do to make this possible.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.