abstraction

Abstraction or not?

The other day i stumbled onto a rather old usenet post by Linus Torwalds. It is the infamous "You are full of bull**" post when he defends his choice of using plain C for Git over something more modern. In particular this post made me think about the enormous amount of abstraction layers that accumulate one over the other where I work. ...

Using Entity Framework with repository pattern in WinForms MDI

Hi, We are about to start up a new project similar to a previous one. I could just copy the old design but I am not all too satisified with the old design. It is a "standard" business system (sales,stocktaking,warehousing etc) built ontop of .Net 3.5 (Winforms MDI) with Entity Framework in the backend. All forms inherit from a basefo...

Form object question

Does anyone have any hard and fast rules about what kind of code the form object should handle as opposed to letting the object itself handle it? For example, if there is a race, should the object that is racing say, horses, handle the race as part of being a horse, or is it better to place that inside the form object? I guess what I'm a...

When do you need to create abstractions in the form of interfaces?

When do you encourage programming against an interface and not directly to a concrete class? A guideline that I follow is to create abstractions whenever code requires to cross a logical/physical boundary, most especially when infrastructure-related concerns are involved. Another checkpoint would be if a dependency will likely change i...

When is abstraction and modularization a bad practice in programming?

just saw this comment in a "what JS lib do you use" poll "@Xanti - yes, yes, modularization and abstraction in programming is a terrible practice. Functions that call other functions? Wasteful." And that left me curious because I am using Kohana framework for PHP and Jquery library for javascript. Why do some people consider abstract...

How to create a "genuinely extensible" class

I have read a lot of articles on developing classes (I am using php), with the tag lines : 'scalable, robust, maintainable and extensible'. But as a beginner, I have been creating classes that are, in my words, "just abstracted". Meaning I just separated a bunch or repetitive codes and put them in a class and provide methods for access...

Using generics in abstract classes.

I'm working on an abstract class where the implementing class needs to implement a list of T. The problem is that this doesn't work: public class AbstractClass { public int Id { get; set; } public int Name { get; set; } public abstract List<T> Items { get; set; } } public class Container : AbstractClass { public List<W...

Connect to a samba share with python in a platform independent manner?

Is there an abstraction that will allow me to connect to a samba share in python regardless of my platform? More information I do not want to mount a share. I simply want to upload files to a share, such as smbclient's put. Thanks, Pete ...

C++ inheritance, base functions still being called when overriden

I have the following two classes, one inherits from the other Class A{ void print(){cout << "A" << endl;} } Class B : A{ void print(){cout << "B" << endl;} } Class C : A{ void print(){cout << "C" << endl;} } Then in another class I have the following: vector<A> things; if (..) things.push_back(C()); else if (..) things.push...

Polymorphic Numerics on .Net and In C#

It's a real shame that in .Net there is no polymorphism for numbers, i.e. no INumeric interface that unifies the different kinds of numerical types such as bool, byte, uint, int, etc. In the extreme one would like a complete package of abstract algebra types. Joe Duffy has an article about the issue: http://www.bluebytesoftware.com/blo...

Is HttpContextWrapper all that....useful?

I've been going through the process of cleaning up our controller code to make each action as testable. Generally speaking, this hasn't been too difficult--where we have opportunity to use a fixed object, like say FormsAuthentication, we generally introduce some form of wrapper as appropriate and be on our merry way. For reasons not pa...

How To Abstract NHibernate To Avoid Tight Dependency and Facilitate Testing

Is it possible to adopt the use of an O/RM like NHibernate or Entity Framework, and abstract it in such a way that it could be replaced if a situation is encountered that the O/RM cannot handle. It seems tempting to create a service with chunky service methods inside of which, a session is created, the session is used to get / upsert e...

Generic function pointers in C

I have a function which takes a block of data and the size of the block and a function pointer as argument. Then it iterates over the data and performes a calculation on each element of the data block. The following is the essential outline of what I am doing: int myfunction(int* data, int size, int (*functionAsPointer)(int)){ //wa...

What's the most used philosophy of keeping independent concepts separate in OOP?

Or according to your own experience, what's your favorite trick ? ...

Making OR/M loosely coupled and abstracted away from other layers.

Hi all. In an n-tier architecture, the best place to put an object-relational mapping (OR/M) code is in the data access layer. For example, database queries and updates can be delegated to a tool like NHibernate. Yet, I'd like to keep all references to NHibernate within the data access layer and abstract dependencies away from the lay...

Objective-C: how to prevent abstraction leaks

I gather that in Objective-C I must declare instance variables as part of the interface of my class even if these variables are implementation details and have private access. In "subjective" C, I can declare a variable in my .c file and it is not visible outside of that compilation unit. I can declare it in the corresponding .h file, a...

Is there a better way than a sequence of if's to handle events?

I recently ran across several objects implemented to handle events with a hard coded mapping using this pattern: public void handleEvent(Event event) { if(event.getCode() == SOME_STATIC_EVENT) doSomething(event); if(event.getCode() == ANOTHER_STATIC_EVENT) doSomethingElse(event); } where doSomething functions a...

The Implications of Modern Day Software Development Abstractions

I am currently doing a dissertation about the implications or dangers that today's software development practices or teachings may have on the long term effects of programming. Just to make it clear: I am not attacking the use abstractions in programming. Every programmer knows that abstractions are the bases for modularity. What I wa...

Are frameworks using byte-code generation creating leaky abstractions?

My point is, if you don't understand the abstraction of a framework, you can still decompile it and understand it, because you know the language e.g. Java. However, when byte-code generation happens, you have to understand even a lower level - JVM level byte-codes. I am really affraid of using any of such frameworks, which are many. Most...

How many layers are between my program and the hardware?

I somehow have the feeling that modern systems, including runtime libraries, this exception handler and that built-in debugger build up more and more layers between my (C++) programs and the CPU/rest of the hardware. I'm thinking of something like this: 1 + 2 >> OS top layer >> Runtime library/helper/error handler >> a hell lot of DLL ...