According to Why define a Java object using interface (e.g. Map) rather than implementation (HashMap), I should declare the most abstract type as possible. However, in some cases I remember, especially for UI related codes, I can’t declare the most abstract type because those UI object usually require to run some child class specific functions, consider Label is a subclass of View in some UI framewor..
Tag : object-oriented
Consider a processing system which ingests objects from an external source and performs extensive processing. One example could be objects detected by a computer vision system which are then fed into a security alert system that looks for particular movement behaviors, and abnormal positi..
Many times while writing MVVM apps in C# I’ve come across this sort of problem where I need to expose the model in a view model so that I can get it in another view model and do something wi..
class ItemList { constructor() { this.list = [];//list holds many instances of Item Class } removeItem(id) { //…search for item in this.list, remove it } } class Item { constructor(parent) { this.id = 123456; this.parent = parent;//ItemList } removeSelf() { this.parent.removeItem(this.id); } } The item class is able to delete itself and the state of ..
I have a class Context, which contains an instance of an abstract class State, which has multiple concrete subclasses (this is an implementation of the State Pat..
I am trying to understand how to design classes which take an input, do some processing, and return a result. More specifically, should the object store the intermediate results between function calls as state, or should all methods be static, and pass params a..
I’m creating images with centered text. I use Python but I’m faced with many question regarding how to write my class.
I know..
I am building a program for a law..
Let’s take French and Japanese adjectives as simple exa..
Disclaimer: I am going to write in Python and in the context of web development with Django, but this question is not language nor framework spe..