ooad

Composite of Commands Design Pattern

心已入冬 提交于 2019-12-12 16:18:14
问题 Does anyone have a good example in Ruby of using a Composite of Commands? It is a design pattern hybrid that I have seen mentioned in various Design Patterns literature which sounds quite powerful, but have not been able to find any interesting use cases or code. 回答1: Inspired by the general idea and the sample pattern implementations in this blog post, here's a stab at what it might look like: class CompositeCommand def initialize(description, command, undo) @description=description;

Refactoring class design to convey the design intention

久未见 提交于 2019-12-11 03:22:54
问题 I have following class design. The complete code is available in " How to achieve this functionality using Generics? ". The code works fine and resolves the casting issue mentioned in " Refactoring Code to avoid Type Casting " In the RetailInvestmentReturnCalculator class, the GetInvestmentProfit() method utilizes CalculateBaseProfit() method present in InvestmentReturnCalculator abstract base class. This fact is not evident from the class design. QUESTION How to refactor this class design to

Business Rule Split among two classes

自闭症网瘾萝莉.ら 提交于 2019-12-10 10:36:37
问题 I have a project allocation domain with the following business rules When a new employee is getting allocated to a project the total expenditure should not exceed the Budget Amount. For an employee the total allocation percentage should not exceed 100% I have created entities as shown below created in C# . QUESTION The Allocate logic is split across two classes – Project and Employee..The List<Allocation> is passed as a parameter to the Allocate method rather than adding as property of the

What's the best way to handle type indicators in object-oriented design? [duplicate]

回眸只為那壹抹淺笑 提交于 2019-12-10 05:13:50
问题 This question already has answers here : Object-oriented design: Saving complex objects (2 answers) Closed 2 years ago . We have a business model that requires, say, different types of vehicles to be identified. For example, motorcycle, boat, yacht, farm equipment, snowmobiles, heavy truck, light truck, passenger car, and "Other". I think there are two ways to handle it: Create a Vehicle class with a few subclasses, say, boat, truck, car and have a single enum indicating the actual type. This

What is Abstractness vs. Instability Graph?

瘦欲@ 提交于 2019-12-09 14:25:40
问题 I recently used NDepend and it produced a good report on my .net assemblies and related pdbs. The most interesting thing I found in the report was abstractness vs. instability graph. I wanted to understand this in real detail, I read their docs and online metrices but it could only help to an extent. Primarily I wish to understand how to evaluate the graph correctly and techniques to control abstractness with stability. There's a very good article here that talks on this but what more in

Use Case diagram - System as an Actor

时光总嘲笑我的痴心妄想 提交于 2019-12-08 14:00:00
问题 Can I include the system as an actor on use case diagram? The system automatically sends emails and/or automatically updates some details of another user. 回答1: Depends. If you have a system that is responsible for sending e-mails - lets call it NOTIFY - and another system - lets call it X - that uses NOTIFY then X can be modelled as an actor of use case Send e-mail that is covered by NOTIFY. On the other hand, NOTIFY itself cannot be modelled as an actor using its own use cases. 回答2: No. The

Issue in using Composition for “is – a “ relationship

此生再无相见时 提交于 2019-12-07 01:06:14
问题 I have system being developed for an HR system. There are Accountant employees and Programmer employees. For the first month of joining the company, the employee is not given any role. One employee can be an Accountant and a programmer at the same time. I have a design shown by the following code. Now, I need to enhance the system by implementing a new functionality: Terminate all Accountants. (Terminate means set status of employee as IsActive = false). The issue is I cannot set all

What's the best way to handle type indicators in object-oriented design? [duplicate]

為{幸葍}努か 提交于 2019-12-05 09:32:22
This question already has answers here : Object-oriented design: Saving complex objects (2 answers) Closed 2 years ago . We have a business model that requires, say, different types of vehicles to be identified. For example, motorcycle, boat, yacht, farm equipment, snowmobiles, heavy truck, light truck, passenger car, and "Other". I think there are two ways to handle it: Create a Vehicle class with a few subclasses, say, boat, truck, car and have a single enum indicating the actual type. This would work, allowing you to represent vehicles that share some common features with common subclasses.

What is Abstractness vs. Instability Graph?

£可爱£侵袭症+ 提交于 2019-12-03 23:53:18
I recently used NDepend and it produced a good report on my .net assemblies and related pdbs. The most interesting thing I found in the report was abstractness vs. instability graph. I wanted to understand this in real detail, I read their docs and online metrices but it could only help to an extent. Primarily I wish to understand how to evaluate the graph correctly and techniques to control abstractness with stability. There's a very good article here that talks on this but what more in addition to this I need is 'how do I control this ? [controlling abstractness with stability]' Abstractness

Derived class Private method is getting called

本秂侑毒 提交于 2019-12-03 23:03:14
问题 I have a Base class pointer pointing to derived class object. The method foo() is public in base class but private in derived class. Base class foo() is virtual. So when i call foo() from Base class pointer, Vptr Table has the address of derived class foo(), BUT its private in Derived class ...so how is it getting called.?? I understand Run time polymorphism and i also understand that the Access specifiers work for compile time and Virtual concept works at run time. So there shall be No