Recommendations on the transition to programming orientation of objects from VB 6 'style'

I am a vb.net developer in a small IT department and I have programming problems solely with objects.

I understand OOP principles, design patterns, unit testing, etc., but when it comes to developing my applications, either my object design is bad, or I skip creating objects altogether. I know how to create unit tests, but I’m not sure what I am creating.

I create almost exclusively data for data input / registration in applications. In most cases, most of the business logic resides in the stored procedure database and UDF. I am an ASP.NET and Winforms application developer for internal and external clients.

I asked about small projects here on the stack, which I can look at to get the idea of ​​good design and testing, but it came mostly shortly. I read a bunch of design books.

What are some good first steps to take apart from my old "VB 6"?

Thanks!

+4
source share
6 answers

I hear you man. I also live in your world. A world in which business people demand reports. Comprehensive reports. Reports that are easily generated with complex stored procedures. In this world, it is easy to think that the database is king, and it controls the application. This line of thought leads to a complex base TSQL code, views, functions, and stored procedures.

Of course, if this is really the report you need, a complex SQL query might be the answer. However, you want to know how to get out of this data-driven world and enter an object-oriented world.

I think typical OO design tutorials will not justify you. Who cares if the dog is a type of animal, and the German Shepherd is a type of dog. This does not explain how you do business at your job. In addition, this is just an example of the inheritance of the TOE. Other OO patterns, such as composition and dependency injection, are much more useful in most cases.

As I think, you should approach the next project or task - temporarily forget about the database. Imagine that you live in a magical world where data from the database should not be received, and writing data back to the database also does not have to happen. You live in a world where your objects are always filled with the right data. First model your objects in this abstract world. After that (then and only then) you will have problems with the confusing implementation of the process of obtaining and writing to the database. The database is only available to save your data. Your data is alive because you have already modeled it in accordance with the rules of your domain.

Understanding UML will greatly help in this type of modeling. First use UML models to model your domain. Then the code for these projects. Then use them to meet the limitations of your database.

Eric Evans "Domain Driven Design" is a great book that clogs this and many other related moments at home. He emphasizes that domain modeling is a critical element in successful application modeling. He further indicates that object-oriented design is better suited for domain modeling than any other type of programming paradigm.

Good luck. After you embrace the fully simulated, fully typed world of objects, you no longer want to parse another dataset again.

+1
source

A coworker got me hooked on a book designed by Eric Evans. It really started to make me move away from data-based development when nessasary.

In addition, participating in a .NET user group in your area will help you find people who are more than willing to help you.

+2
source
  • Try reading the code from projects that were developed in accordance with OOP aproach.

  • Imagine what your code looks like if you code as an example that you are reading.

  • Be tough with your own code, try it until you are satisfied, and then after reading it after 3 months, you will find many other new things to improve it.

  • Remember the KISS rule, all parts will work because you still code the following OOP principles.

  • Be disciplined. It’s easy to give in to the old, but not to give up.

Remember the words of Diistra: ... when you do something quickly and dirty, you suddenly imagine that I look over your shoulders and say to yourself: “Dijkstra would not like it,” well, for me it would be immortality.

He lives inside each of us =). And you did the most important thing, you really want to know how to do it. This is a major hurdle with VB6 developers when they change to VB.NET.

  • In VB6, this is easier.
  • VB6 always works faster.
  • The same ... just looks better.
  • VB6 has a lot more features.

Looks familiar?

0
source

There are two things that I would recommend:

  • Look at the UML class diagrams and play around with the class diagram tool in Visual Studio. The goal of OOP is to make things more “conceptual” by thinking about objects and, at least for me, class diagrams help with this.
  • Read some good design patterns such as the Decorator or Factory pattern. Since most design patterns make full use of object-oriented design and are generally well described, they can really help to understand the concepts.
0
source

I was in your place a few years ago. I remember reading an article in which it was estimated that you would spend from 6 months to a year just reading about object-oriented development before you start to “receive”.

I started by simply trying to introduce objects into my daily procedural programming. Then I tried to get as much processing as possible from the user interface. Then I tried to create “layers” for my business logic and data access. I understand that your database already has a lot of your business logic, but it would not hurt to have a BL layer in place if that changes. Right now, it can pretty much function as a passage.

I have Eric Evan Domain-Driven Design that I still need to read, but a few books that have helped me: “The Object Oriented Thought Process ” and the one I'm reading now, Microsoft.NET: Archiving Applications for the Enterprise . ”This Book , although perhaps more than you really need right now, is the first that helped me understand the layers and how to implement them.

In any case, good luck on your journey. Just remember that it will be a process, not a destination!

0
source

In addition to the tips provided in other answers, you should push through VB.NET and learn C #.

It will not do everything for you, but it will help you get out of your old thinking.

-1
source

All Articles