abstraction

guidance with OO design of my UML diagram

喜欢而已 提交于 2019-12-13 05:13:31
问题 Could I please get some feedback on this UML diagram? It's a simplified diagram only showing the layout and interconnectivity of the classes with instance variables, constructors and methods intentionally left out at this point in time. Inventory Project Simplified UML Diagram The main thing I need guidance with is the object-oriented design. Do I have the right classes implementing interfaces or should I move the interface(s) to subclass(es)/superclass(es), do I have the association,

Name for a function that maps and returns a resolved array of promises?

送分小仙女□ 提交于 2019-12-13 02:12:29
问题 Maybe this is a stupid ask but I recently found myself using this abstraction often: async function giveMeAName(cbAsync, initValue) { return await Promise.all( initValue.map(cbAsync), ); } Question: Is this a common task to anyone else? If so, does it have a name? If not, maybe it's only partly realize, so does it remind you of anything? Otherwise, I can just delete the question. Currently I'm using this function for this set of instructions. Code below will get all directories of a path and

Should I use integer ID or pointers for my opaque objects?

烂漫一生 提交于 2019-12-12 11:01:50
问题 I'm writing an abstraction layer on top of some graphics API (DirectX9 and DirectX11) and I would like your opinion. Traditionally I would create a base class for each concept I want to abstract. So in typical OO fashion I would have for example a class Shader and 2 subclasses DX9Shader and DX11Shader. I would repeat the process for textures, etc... and when I need to instantiate them I have an abstract factory that will return the appropriate subclass depending on the current graphics API.

How can I write a Trait in Julia with open-ended types?

一个人想着一个人 提交于 2019-12-12 10:45:27
问题 This is an attempt to simplify one part of the question I asked here: I want to write some code that is guaranteed to work on types that meet certain criteria. Let's say today I write some code: immutable Example whatever::ASCIIString end function step_one(x::Example) length(x.whatever) end function step_two(x::Int64) (x * 2.5)::Float64 end function combine_two_steps{X}(x::X) middle = step_one(x) result = step_two(middle) result end x = Example("Hi!") combine_two_steps(x) Running this works:

Exceptions and Abstractions

吃可爱长大的小学妹 提交于 2019-12-12 08:57:14
问题 When should you throw a custom exception? e.g. I have some code that connects to a server. The code that connects to the server throws an IOException when it fails to connect. In the context of the method it's called, this is fine. It's also fine in the network code. But as this represents not having a connection (and therefore not working) the exception goes all the way up to the ui. At this stage, an IOException is very ambigous. Something like NoConnectionException would be better. So, my

Fatal error: Class NAME not found in (…PATH)?

跟風遠走 提交于 2019-12-12 05:18:15
问题 What may be the problem if i get the following error. while i am extending a class i got this error example: class ModuleUser extends AbstractModule Fatal error: Class AbstractModule not found in (....PATH) ? I have done most of the possibilities... But i can't resolve the problem. any help will be thankful thanks n advance Fero 回答1: Prior to your definition of ModuleUser, import the file that contains the definition for AbstractModule. require_once 'path/to/abstract_module.php'; If both

Android Realm Abstract Class Instantiate

妖精的绣舞 提交于 2019-12-12 03:11:31
问题 I am trying to setup an AuotoCompleteTextview (in my MainActivity) where data is fetched from Realm database. So I'm using an adapter as following: public abstract class FilterableRealmBaseAdapter<T extends RealmObject> extends ArrayAdapter<T> implements Filterable { private final RealmResults<T> mRealmObjectList; private List<T> mResults; public FilterableRealmBaseAdapter(Context context, @LayoutRes int layout, RealmResults<T> realmObjectList) { super(context, layout); mRealmObjectList =

PHP5 & Abstract Classes. Separate copy of class variables for each child class?

夙愿已清 提交于 2019-12-11 18:57:58
问题 Let's see if I can describe this properly... I have an abstract class that when other classes extend from it, I'd like for the abstract class' data to be reset to zero. The idea being that I have a pile of classes extending this and using MySQL table's for data structure. I don't want to query the DB with every class instantiation to determine the class' data ("SHOW COLUMNS FROM tablename ). So for every class, I'd like for it to each "Have we created this class before? If so, we know the

How to extract current Android layout segments into their own custom control?

旧巷老猫 提交于 2019-12-11 14:54:58
问题 OK, I have a complete layout built; however, I am not really pleased with the long xml file that has resulted. I have a shorted version of the xml outline and designer view below. And I was wondering how I can abstract out each group of similar components into their own custom control. For example, in the picture below, I have highlighted one such control that I would like to abstract out. Instead of it being a LinearLayout with 2 TextView 's inside with their own properties and attributes

abstracting over a collection

荒凉一梦 提交于 2019-12-11 04:40:42
问题 Recently, I wrote an iterator for a cartesian product of Anys, and started with a List of List, but recognized, that I can easily switch to the more abstract trait Seq. I know, you like to see the code. :) class Cartesian (val ll: Seq[Seq[_]]) extends Iterator [Seq[_]] { def combicount: Int = (1 /: ll) (_ * _.length) val last = combicount var iter = 0 override def hasNext (): Boolean = iter < last override def next (): Seq[_] = { val res = combination (ll, iter) iter += 1 res } def