abstraction

How do I Modular Design in C?

南笙酒味 提交于 2019-12-06 09:17:44
问题 I want to make my project more modular so that there are no inter-modular dependencies if one of the module is removed. For e.g. If I divide the code in my process into multiple directories, say, X, Y and Z so that data structures in X should not be accessed directly by data structures in Y and Z and vice versa then I need some internal communication mechanism between X, Y and Z. Since I am coding in C, can anyone suggest a sample project or design considerations for the same? 回答1: This often

Is it possible to use JDBC as an abstraction layer for RDBMS?

跟風遠走 提交于 2019-12-06 06:02:17
JDBC provides an API, which may be used to connect to different RDBMS or similar datastores. But the datastores differ in implementation (e.g. SQL dialects). Is it possible to use JDBC in such a way, that my queries and statements work on most common RDBMS (e.g.: Oracle, PostgreSQL, SQL Server, MySQL)? That question is interesting for me at two aspects: * Common SQL (INSERT, UPDATE, SELECT etc.) * Accessing Meta data (getting information about tables and columns) I am currently experimenting with an self written persistence framework and want to plug a JDBC datastore under it. So if I write a

Is having a wrapper for your IoC a good idea?

≡放荡痞女 提交于 2019-12-06 05:19:05
I have been using StructureMap for more than a year now. And all this time I used to have a wrapper class called IoC which looked like this class IoC { public static T GetInstance<T>() { return (T)GetInstance(typeof(T)); } public static IEnumerable<T> GetAllInstances<T>() { return ObjectFactory.GetAllInstances<T>(); } public static IEnumerable GetAllInstances(Type type) { return ObjectFactory.GetAllInstances(type); } public static object GetInstance(Type type) { return ObjectFactory.GetInstance(type); } public static void Inject<T>(T obj) { ObjectFactory.Inject(obj); } } I added the wrapper

Design(How-to) of classes containing collections of other classes

删除回忆录丶 提交于 2019-12-06 03:33:33
问题 How to design classes involving collections of other classes? General Example: A Workspace contains number of Projects . A Project contains large number of Resources . Each Resource may contain large number of Files . So here the classes identified can be Workspace,Project,Resource and File. Workspace will have list of Project.Project will have list of Resources and Resource will have list of Files. Of course each class has its related settings. Now the basic questions are : a) Who creates

difference between encapsulation and abstraction concepts [duplicate]

独自空忆成欢 提交于 2019-12-06 01:18:18
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Abstraction VS Information Hiding VS Encapsulation Can somebody explain to me the main differences between the principles of encapsulation and abstraction in objected-oriented programming (if possible with examples). 回答1: Sample: // NO ABSTRACTION, NO ENCAPSULATION const int catLegs = 4; const int spiderLegs = 8; Leg[] catLegs; Leg[] spiderLegs; void MakeCatRun(Distance b) { for (int i=0; i<catLegs; ++i) catLegs

Sharing functions between namespaces in Clojure

痞子三分冷 提交于 2019-12-05 19:31:03
问题 I may very well be approaching this in the wrong way, so please forgive me of my naiveté: In order to learn Clojure I've begun porting my OAuth client library for Python to Clojure. I'm doing this by wrapping clj-http much in the same way I wrap Python Requests in the Python library. This seems to be working pretty well so far and I'm really enjoying seeing the implementation come to life in Clojure. However I have run into a problem: I'm planning to support both OAuth 1.0 and 2.0 and have

C++ zero-cost abstraction for SoA/AoS memory layouts

人走茶凉 提交于 2019-12-05 09:13:05
Say I have a large code using Array of Structures (AoS) memory layout. I would like to build a zero-cost abstraction in C++ which allows me to switch between AoS and SoA with as little refactoring effort as possible. For instance take a class with access member functions struct Item{ auto& myDouble(){ return mDouble; } auto& myChar(){ return mChar; } auto& myString(){ return mString; } private: double mDouble; char mChar; std::string mString; }; which is used inside a container in a loop std::vector<Item> vec_(1000); for (auto& i : vec_) i.myDouble()=5.; I would like to change the first

Cakephp: Abstracting AppController another level, possible?

こ雲淡風輕ζ 提交于 2019-12-05 08:04:21
I was wondering if it's somehow possible to add another abstraction controller between AppController and my app's other controllers? So that my controllers, e.g. UsersController extends SecureController and SecureController extends AppController. Also I want to be able to have other controllers extend AppController directly: SomeNonSecureController extends AppController. this is because my current AppController has all sorts of Auth and ACL stuff in its beforeFilter, but i also have controllers that don't need that security stuff (before everything needed the security, no new specs have been

Design of interface abstraction

╄→гoц情女王★ 提交于 2019-12-05 05:03:01
Currently, I try to write a small game program (Skat) as a hobby project. Skat is a trick-taking game were two players play against a single player. As there are different kinds of players (lokal player, network player, computer, etc.), I wanted to abstract the interface to the player. My basic idea is to use a typeclass Player , that defines all kind of things, a player have to do and to know (playing a card, get notified about who won the trick, etc). Then, the whole game is just done by a function playSkat :: (Player a, Player b, Player c) => a -> b -> c -> IO () where a , b and c might be

DataBinding: How to use BaseActivity / How to use Abstraction

老子叫甜甜 提交于 2019-12-05 02:29:25
I am trying to add DataBinding to my app. In my app, I have a BaseActivity which has a Toolbar and a FrameLayout. FrameLayout is container for activities' which extend the BaseActivity. How can I add databinding to both my BaseActivity and the extending activities? I'll share my code without DataBinding: Here is my BaseActivity.java : public class BaseActivity extends AppCompatActivity { @Override public void setContentView(@LayoutRes int layoutResID) { LinearLayout container = (LinearLayout) getLayoutInflater().inflate(R.layout.activity_base, null); FrameLayout activityContent = (FrameLayout)