abstraction

How can I abstract out the core functionality of several Rails applications?

I'd like to develop a number of non-trivial Rails applications which all implement a core set of functionality but each have certain particular customizations, extensions, and aesthetic differences. How can I pull the core functionality (models, controllers, helpers, support classes, tests) common to all these systems out in such a way t...

Invoking code both before and after WebControl.Render method

I have a set of custom ASP.NET server controls, most of which derive from CompositeControl. I want to implement a uniform look for "required" fields across all control types by wrapping each control in a specific piece of HTML/CSS markup. For example: <div class="requiredInputContainer"> ...custom control markup... </div> ...

How to check at runtime if a class implements certain interface?

Let's say I have some content classes like Page, TabGroup, Tab, etc. Certain of those will be implementing my IWidgetContainer interface - it means they will geet an additional field named ContainedItems from the interface and some methods for manipulating this field. Now I need to reflect the fact that some class implements this interf...

How much abstraction is too much?

In an Object Oriented Program: How much abstraction is too much? How much is just right? I have always been a nuts and bolts kind of guy. I understood the concept behind high levels of encapsulation and abstraction, but always felt instinctively that adding too much would just confuse the program. I always tried to shoot for an amoun...

.NET Forms Abstraction for WPF, Silverlight, Winforms, WebForms, etc...

Anyone know of a project(s) that seek to abstract form definitions on level higher than WPF, Silverlight, Winforms, WebForms, etc... I'm working on a project where we are fixing up 16 somewhat simple WebForms. But we may convert (and probably will convert to WPF or Silverlight 3 to 4 months from now. I'd rather define these forms once ...

Is an ORM redundant with a NoSQL API?

Hello, with MongoDB (and I assume other NoSQL database APIs worth their salt) the ways of querying the database are much more simplistic than SQL. There is no tedious SQL queries to generate and such. For instance take this from mongodb-csharp: using MongoDB.Driver; Mongo db = new Mongo(); db.Connect(); //Connect to localhost on the d...

Curiosity beyond abstractions: how is bytecode executed? how do device drivers work?

Everything I've seen on *nix has been a set of abstractions off hardware, but I'm curious as to how the hardware works. I've programmed in assembly, but that's still only a set of abstractions. How does a processor understand assembly opcodes (as bytecode)? How do device drivers work (with an explanation at a lower level (of abstracti...

Create a new instance in a static function of an abstract class

abstract class db_table { static function get_all_rows() { ... while(...) { $rows[] = new self(); ... } return $rows; } } class user extends db_table { } $rows = user::get_all_rows(); I want to create instances of a class from a static method defined in the abstract pa...

Dealing with multiple generics in a method call

I've been dealing a lot lately with abstract classes that use generics. This is all good and fine because I get a lot of utility out of these classes but now it's making for some rather ugly code down the line. For example: abstract class ClassBase<T> { T Property { get; set; } } class MyClass : ClassBase<string> { OtherClass P...

Running time assumptions in Ruby

Ruby looks a very cool language. I've started learning it for the past two three days. One thing that appeals me in Ruby is its simplicity. Very clean code is possible. However, the internal implementations of Ruby is not exposed to the outside world. I learnt that Ruby is written in various languages depending on the flavors. The one ...

DRYing out implementation of ICloneable in several classes

I have several different classes that I want to be cloneable: GenericRow, GenericRows, ParticularRow, and ParticularRows. There is the following class hierarchy: GenericRow is the parent of ParticularRow, and GenericRows is the parent of ParticularRows. Each class implements ICloneable because I want to be able to create deep copies ...

Is it better to use List or Collection?

I have an object that stores some data in a list. The implementation could change later, and I don't want to expose the internal implementation to the end user. However, the user must have the ability to modify and access this collection of data. Currently I have something like this: public List<SomeDataType> getData() { return this....

Explaining abstraction to a non-programmer.

Abstraction is a concept that seems difficult to explain, without reverting to using programming terminology. I've thought about it a lot, and I can't come up with a satisfactory answer. Does anyone have any very general, yet very pertinent explanations? Metaphors, similes etc are all welcome. ...

How Does One Make Scala Control Abstraction in Repeat Until?

Hi I am Peter Pilgrim. I watched Martin Odersky create a control abstraction in Scala. However I can not yet seem to repeat it inside IntelliJ IDEA 9. Is it the IDE? package demo class Control { def repeatLoop ( body: => Unit ) = new Until( body ) class Until( body: => Unit ) { def until( cond: => Boolean ) { body; ...

synchronizing XML nodes between class and file using C#

I'm trying to write an IXmlSerializable class that stays synced with an XML file. The XML file has the following format: <?xml version="1.0" encoding="utf-8" ?> <configuration> <logging> <logLevel>Error</logLevel> </logging> ...potentially other sections... </configuration> I have a DllConfig class for the whole XML file an...

Protocol abstraction in C#

There are dozens of network protocols and file formats (WAV, TCP, BMP, etc. etc.) Is there a solution available to create an abstraction layer between the implementation of a protocol and the code that uses the resulting data? Take a WAV file. A software component could contain logic to identify chucks and parse them into classes. The ...

Abstracting away from data structure implementation details in Clojure

I am developing a complex data structure in Clojure with multiple sub-structures. I know that I will want to extend this structure over time, and may at times want to change the internal structure without breaking different users of the data structure (for example I may want to change a vector into a hashmap, add some kind of indexing ...

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

Hi Everyone, 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 ...

How do I represent tiles in XML?

So, I'm writing an AS3 program that tiles floor tiles. I want the user to be to be able to create their own floor schematic represented by different rectangles. It'll be drag-and-drop. They will lay out their schematic (which is composed of different size rectangular tiles) and drop colors/patterns onto them. This schematic will then be...

can backtracking be avoided when trying to minimize the rectangle space that encloses rectangles of different integer shapes?

The abstraction of my problem is that in a cartesian plane there are a lot of rectangles. These rectangles have known integer sizes and must have integer coordinates(their abscissas are known and fixed, only their ordinates may vary). The problem is to find those ordinates for which the smallest rectangle that contains all the given rec...