constructor methods in interfaces
Are constructor methods in interfaces bad? ...
Are constructor methods in interfaces bad? ...
In a lot of languages with simple OO capability (PHP 4), or misunderstood OO capabilities (Javascript, C using function pointers, etc.), you'll end up with a function naming convention that uses leading underscores to to indicate privilege level. //ex. function _myPrivateFunction(){ } While individual teams are always going to come...
Okay, it took me a little while to narrow down this problem, but it appears python is doing this one purpose. Can someone explain why this is happening and what I can do to fix this? File: library/testModule.py class testClass: myvars = dict() def __getattr__(self, k): if self.myvars.has_key(k): return sel...
In the interest of reusing some existing code that was defined as an instance method of a different class, I was tying to do something like the following: class Foo(object): def __init__(self): self.name = "Foo" def hello(self): print "Hello, I am " + self.name + "." class Bar(object): def __init__(self): self.name =...
Hello There http://stackoverflow.com/questions/742097/this-a-b-c-d-calling-methods-from-a-superclass-in-php Ive asked a question on this link I ve problem with this tecnique I am able to call the sub classes from a class like this $chesterx->db->query(); I wanna do get another class from sub class for example i want to query exe...
I’m trying to use the MVP pattern and I’m running into a design problem. I’m developing an application that will have several UserControls. The UserControls themselves have nothing to do with one another and only represent a subset of the actual model. From what I’ve read, people tend to say you should use one Presenter per View. Thi...
Abstract classes are described as being useful for a family of objects (e.g. could be used for animals which are mammals). However, what difference is there between using an interface or abstract class for representing a family of related objects? My process is to use an abstract class when I want to define common functionality but with...
I am designing a class where some methods won't cause any harm if they are exposed as public. But they can be private as well, since they will be used only from the same class in my project. Making them public has the following advantages: Unit Testable without the need of accessors. Flexibility. Making them private has the followin...
I usually try to do TDD with not much analysis (no diagrams) before start coding. Usually I find myself spliting a class into other classes to separate concerns. I wonder if a deeper analysis would prevent that. I think that much of OO analysis can't predict some of those cases. What do you think? ...
What if I have a class that both extends an abstract class and implements an interface, for example: class Example : AbstractExample, ExampleInterface { // class content here } How can I initialize this class so I can access methods from both the interface and the abstract class? When I do: AbstractExample example = new Example(...
(I'm sure this is a FAQ, but also hard to google) Why does Python use abs(x) instead of x.abs? As far as I see everything abs() does besides calling x.__abs__ could just as well be implemented in object.abs() Is it historical, because there hasn't always been a root class? ...
Hi! I'm developing a Cocoa (Touch) app and there's certain data (like own device information and a list of locations) that I have to persist between different views and controllers. I thought of storing it as instance variables in my App Delegate, but addressing the delegate is quite cumbersome (no joy typing [[[UIApplication sharedAp...
Assume I have a composite relationship, say a Customer having a collection of Orders (and assuming an Order cannot exist without an "owning" Customer.) So, I'm not talking about aggregation. What terms are used to describe the roles in this relationship? I might say the Customer is the "owner" of an Order and maybe the Order is "owned"...
I know the difference between "public interface" and "public abstract interface", but when applied on methods are there differences? public interface IPluggableUi { abstract public JComponent getPanel(); abstract public void initUi(); } or public interface IPluggableUi { public JComponent getPanel(); public void initU...
I'm reading a HTTP POST and the body of the HTTP request can be either JSON or XML. Now I've delegated the reading to a special utility class. interface HttpUtils { BodyWrapper parseBody( HttpServletRequest req ); } interface BodyWrapper { boolean isXML(); // 1 boolean isJSON(); // 2 String body(); // 3 } I hate ...
Is there a way to make like a template singleton class so that when you extend it, the extended class is also a singleton class, so I can quickly make a new singleton class just my extending the template singleton class? I am using ActionScript 3.0 if it matters. Thanks. ...
I make a lot of "design your own ____" applications. What I do is I make a singleton class to hold all the customizations the user has chosen. For example: When you select you want something green, it updates a getter/setter in the singleton to be green. Then when the application needs to know what color was selected it gets the info fro...
Found myself trying to find a link to an official definition of this design pattern which I believe I saw in Go4 but can't seem to find it anywhere. class Processor{ ProcessParameter(AbstractParameter x){ x.Process(this); } ProcessParameter(ParameterA x){ ... A-specific logic... } ProcessParameter(Paramet...
I have three classes interacting in an interesting way. One is a model class, and it has to be accessed by both of the other classes, so a single instance of it is kept as a member of each. Both of these classes interact with the model in different ways. There are a couple of instances where the model object has to be completely throw...
Context (example): In windows explorer in "Folder Options" there is a section called "Advanced Settings" where "settings" is a set of pairs (name : value), e.g. "Do not cache thumbnails" : On "Hidden files and folders" : "Do not show hidden files and folders" What is a correct name for each of those pairs? Is it "setting"? Questi...