开发者

Design classes - OOPS features

开发者 https://www.devze.com 2022-12-11 01:48 出处:网络
I am interested in improving my designing capability (designing of classes with its properties, methods etc) for a given.

I am interested in improving my designing capability (designing of classes with its properties, methods etc) for a given. i.e. How to decide what should be the classes, methods a开发者_开发百科nd properties?

Can you guys suggest me good material for improving on this?


Please see:

Any source of good object-oriented design practises?

Best Resources to learn OO Design and Analysis

among many....


  1. Encapsulation: The wrapping up of data and functions into a single unit is known as encapsulation. Or, simply put: putting the data and methods together in a single unit may be a class.

  2. Inheritance: Aquiring the properties from parent class to child class. Or: getting the properties from super class to sub class is known as inheritance.

  3. Polymorphism: The ability to take more that one form, it supports method overloading and method overriding.

    Method overloading: When a method in a class having the same method name with different arguments (diff parameters or signatures) is said to be method overloading. This is compile-time polymorphism – using one identifier to refer to multiple items in the same scope.


This is perhaps a question which every programmer thinks of one day. The designing capability comes with your experience gradually. What I would say is in general scenario if you can visualize the Database objects for a given problem, the rest is a cakewalk (isnt true sometimes if you work on a techie project with no DB)

You can start thinking of objects which are interacting in the real world to complete the process and then map them to classes with appropriate properties and then methods for defining their behavior. Ten you can focus on the classes which contribute to running the workflow and not to any individual real world object.

This gets a lot simplified if we focus on designing the DB before we jump directly to code design.

A lot depends on the pattern you choose - If you see a problem from MVC perspective, you will naturally be drawn towards identifying "controller" classe first and so on.

I guess I need not repeat the golden sources of design and OOPS wisdom - they already posted here or there.


I would recommend you to read up on some UML and design patterns. That gets you going with the thinking in "drawing" terms. You can also get a good grasp of a big class/object a lot easier.

One particular book that is good in this area. Applying UML and Patterns


Give a look a Domain-Driven Design, which defines entities, value objects, factories, services and repositories and the GRASP patterns (General Responsibility Assignment Software Patterns) e.g. Expert, Creator, Controller.


Have a look at the part 1 screencast the first part is not silverlight but just a command line calculator that starts out as a single bit of code, and is then broken down into classes.

0

精彩评论

暂无评论...
验证码 换一张
取 消