object-oriented-analysis

Cahining pattern

若如初见. 提交于 2019-12-12 00:43:59
问题 I have a class in php that works with the chainning method, but the problem is that I want to chain the methods in some order. class Chain { public function foo () { return $this; } public function bar () { return $this; } public function some () { return $this; } } So, if I use this class, then I can chain this methods in 9 different ways (all the possible combinations of 3 elements) But what happen if I determine that the method some always must to be chained after foo or bar and not in

Output of class function in Matlab

▼魔方 西西 提交于 2019-12-11 11:42:20
问题 I'm working with classes a long time ago but yet I couldn't get one thing that how to OUTPUT from a function/Constructor of like a function. I have seen multiple examples but coulnd't clear the point. Here I'v a simple example of myFunc outputting an array, and same function in class, How to output from class like a function. How to take output from any function of class just like a function? myFunc: function M=myFunc(n) [M]=[]; i=0; for ii=1:n M(ii)=i; %% Counter i=i+4; end end MyClass:

Avoiding static methods and variables in a Java Class file that handles config.properties

自作多情 提交于 2019-12-10 15:37:47
问题 I am working on a simple Java Application and I've created a class called Config.java in order to handle the Application properties, thus, avoiding hard-coding. The Config.java class is not a static class, and I am creating an instance of the Config.java class in another class called Serial.java. The main method is located in another Class called App.java. So I have 3 Classes in total: App.java Serial.java (Instance of Config class is located here as a private variable) Config.java At this

Is Method Overloading a Type of Polymorphism? [duplicate]

こ雲淡風輕ζ 提交于 2019-12-10 11:24:59
问题 This question already has answers here : Is Method Overloading considered polymorphism? [closed] (8 answers) Closed 5 years ago . I was studying about static and dynamic polymorphism and got these links: http://guruzon.com/1/oop-concepts/polymorphism/what-is-polymorphism-example-tutorial-uml-diagram-notation http://www.coderanch.com/t/379004/java/java/static-polymorphism-dynamic-polymorphism http://javarevisited.blogspot.in/2011/08/what-is-polymorphism-in-java-example.html In all these links

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

Is Polymorphism a waste to apply for the classes that we exactly know the type prior run-time?

偶尔善良 提交于 2019-12-08 12:33:26
问题 Run-time Polymorphism can be used to let the run-time to dynamically load the exact concrete class of an abstract class/interface. (You can take Animal/Dog, Vehicle/Car examples) But when we know the exact concrete class @coding-time (compile-time), does it really need to forcefully apply polymorphism? 回答1: When I write OO code, I tend to use most-general type I can on the left-hand side of the assignment. This immediately means that my answer to your question is - no. Here's the example:

Can I apply here Liskov substitution principle

拈花ヽ惹草 提交于 2019-12-08 00:08:45
问题 I have two data models which are represented by the following classes: 1) ImagesSet - an object that owns 2DImage 's, each 2DImage has its own position (origin( 3DPoint ), x-,y-axes( 3DVector ) and dimension along x and y axes(in pixels)), but the same pixel size(in mm for example), angle between x and y axes(90 degrees) This object has following methods(in pseudo code): AddImage(2DImage); RemoveImage(ImageIndex); number GetNumberOfImages(); 2DImage Get2DImage(ImageIndex); 2) 3DImage - an

Difference between Sequence & Communication Diagram (UML) [closed]

情到浓时终转凉″ 提交于 2019-12-06 11:31:49
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . What is the difference between sequence diagrams and communication (collaboration) diagrams in UML? 回答1: Quoting Wikipedia: Communication diagrams show a lot of the same information as sequence diagrams, but because of how the information is presented, some of it is easier to find

Is Method Overloading a Type of Polymorphism? [duplicate]

前提是你 提交于 2019-12-06 06:14:59
This question already has answers here : Is Method Overloading considered polymorphism? [closed] (8 answers) Closed 5 years ago . I was studying about static and dynamic polymorphism and got these links: http://guruzon.com/1/oop-concepts/polymorphism/what-is-polymorphism-example-tutorial-uml-diagram-notation http://www.coderanch.com/t/379004/java/java/static-polymorphism-dynamic-polymorphism http://javarevisited.blogspot.in/2011/08/what-is-polymorphism-in-java-example.html In all these links , It has been said that Overloading is an example of polymorphism , then I came across two more places

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.