ooad

Try / Catch in Constructor - Recommended Practice?

笑着哭i 提交于 2019-12-28 12:01:43
问题 Something I've always been curious of public class FileDataValidator { private String[] lineData; public FileDataValidator(String[] lineData){ this.lineData = lineData; removeLeadingAndTrailingQuotes(); try { validateName(); validateAge(); validateTown(); } catch(InvalidFormatException e) { e.printStackTrace(); } } //validation methods below all throwing InvalidFormatException Is is not advisable to include the try/catch block within my Constructor? I know I could have the Constructor throw

Try / Catch in Constructor - Recommended Practice?

一笑奈何 提交于 2019-12-28 12:01:14
问题 Something I've always been curious of public class FileDataValidator { private String[] lineData; public FileDataValidator(String[] lineData){ this.lineData = lineData; removeLeadingAndTrailingQuotes(); try { validateName(); validateAge(); validateTown(); } catch(InvalidFormatException e) { e.printStackTrace(); } } //validation methods below all throwing InvalidFormatException Is is not advisable to include the try/catch block within my Constructor? I know I could have the Constructor throw

Method Calling Public/Private Members or Methods Best Practice - C#.NET

做~自己de王妃 提交于 2019-12-19 17:47:23
问题 What is the best practice for calling members/fields from a private method and public method? Should the private method always call private fields or should they call the public members? private string _name; public string Name { get {return _name; } set { _name = value; } } public void DoSomething() { _doSomething(); } private void _doSomething() { _name.ToLower(); } 回答1: I prefer to have all code go through the public interface, simply to reduce the number of places in the code that

Difference between Sequence Diagram (SD) and a System Sequence Diagram (SSD)?

谁说胖子不能爱 提交于 2019-12-18 18:51:01
问题 I'm working on a project for a grad class and still having trouble wrapping my head around them. What is the difference between a sequence diagram (SD) and a system sequence diagram (SSD) ? And in what order should they be developed when working on a systems development project? 回答1: A System sequence diagram visualizes a use case, while a sequence diagram visualizes a method of a class. The elements participating (exchanging messages) in a system sequence diagram are Actors and Systems. The

What is an anti-pattern?

只愿长相守 提交于 2019-12-17 17:23:19
问题 I am studying patterns and anti-patterns. I have a clear idea about patterns, but I don't get anti-patterns. Definitions from the web and Wikipedia confuse me a lot. Can anybody explain to me in simple words what an anti-pattern is? What is the purpose? What do they do? Is it a bad thing or good thing? 回答1: Anti-patterns are certain patterns in software development that are considered bad programming practices. As opposed to design patterns which are common approaches to common problems which

Abstract base class to force each derived classes to be Singleton

梦想的初衷 提交于 2019-12-17 16:33:14
问题 How do I make an abstract class that shall force each derived classes to be Singleton ? I use C#. 回答1: When you want to enfore compile time checking, this is not possible. With runtime checking you can do this. It's not pretty, but it's possible. Here's an example: public abstract class Singleton { private static readonly object locker = new object(); private static HashSet<object> registeredTypes = new HashSet<object>(); protected Singleton() { lock (locker) { if (registeredTypes.Contains

Is Information Expert from GRASP and Modell from MVC the same?

佐手、 提交于 2019-12-13 05:17:39
问题 I just started to read the Applying UML and Patterns(2nd edition) book. Is one of the GRASP Patterns the Information Expert, equivalent with the Modell form MVC? Do they have the same responsibilities(Storing and retrieving information)? 回答1: Is Information Expert from GRASP and Modell from MVC the same? Yes and No. Do they have the same responsibilities(Storing and retrieving information)? No. Information expert's eligibility is not restricted to storing and retrieving information. It is

responsibility of each class and how they interact each other in UML

纵饮孤独 提交于 2019-12-13 03:32:14
问题 I'm trying to draw an class diagram for my project management software describing the following scenario. It contains project Manager Employee Manager can create project manager can change project deadline manager can change project name manager can assign a employee To Project (single project have only one assigned employee) employee can submit project For the above requirements created this Class diagram and implement it in code using php as shown below Class Manager { private $Id; private

Inheritance and interfaces

假装没事ソ 提交于 2019-12-12 19:52:18
问题 This is somewhat of a follow-up question to this question. Suppose I have an inheritance tree as follows: Car -> Ford -> Mustang -> MustangGT Is there a benefit to defining interfaces for each of these classes? Example: ICar -> IFord -> IMustang -> IMustangGT I can see that maybe other classes (like Chevy ) would want to implement Icar or IFord and maybe even IMustang , but probably not IMustangGT because it is so specific. Are the interfaces superfluous in this case? Also, I would think that

What's the UML syntax for multiplicity? ( inside the class box )

≯℡__Kan透↙ 提交于 2019-12-12 17:33:25
问题 I know it is possible to specify the multiplicity within the same class box, without having to draw the link to another class. My question is, Where should the multiplicity go, after the name or after the type? Is it: visibility name multiplicity : type as + clients [0..n] : Client or visibility name : type multiplicity as + clients : Client [0..n] I have two books (Applitying UML and Patterns by Larman and UML and the Unified process by Arlow and Newstadt ) but they differ 回答1: Pulled from