abstraction

What is Joel's "two levels of abstraction"?

I was listening to the Stack Overflow Podcast #34 (59:00 - 1:02:00) and Joel mentioned the difficulty of pointers and recursion. He also mentioned thinking in two levels of abstraction. He also mentions these concepts in his Peril of JavaSchools article. .... But when you struggle with pointers, your program produces the line S...

When is enough abstraction enough?

I was having a conversation with a co-worker a few days ago. When I mentioned that a new coding technology he's interested in doesn't seem like anything that couldn't already be done with existing tools rather easily, he replied a bit dismissively, "that's what they said about object-oriented programming, too. It's just procedural progr...

When is enough abstraction enough

I tried asking this and it got closed very quickly for being too long. (Which it was.) But I think it's a genuine question that needs to be discussed, so here's a much shorter version: Abstractions are supposed to simplify your code. But in my experience maintaining other people's code, I consistently find that the trade-off for making ...

Why higher order procedures??

So if a language provides higher order procedure then I can have procedure that returns procedure... something like (define (Proc a b c) (lambda (x) ( // method body here in terms of a b c and x))) To create new proc I would just do something like.. (define ProcA (Proc a1 b1 c1)) // Would create ProcA that has 1 argument Similar task...

How do I create two mutual producer/consumers with internal state in Haskell?

I've got an agent that takes in states and returns actions, while keeping an internal representation of the utility of state/action pairs. I've also got an environment that takes in actions and returns state/reward pairs. I need to be able to set the agent up with a start state and then continuously go from agent -(action)-> environment...

Elegant way of holding large static typesafe dictionary in java - or avoiding code too large

Basically I would like to have some dictionary that is an abstaction over legacy #define directives. I have an old header file that contains 6000+ defines, that are used as flag parametersome function and these defines denote one type of entity parameter. In C i have GetParameter(... , T_CTITLE, ...); In Java i would like to call...

Message forwarding in Smalltalk

So I'm writing an application where one object has a bunch of delegate objects that it forwards messages to. The idea is that I can say someObject sendMessage:aMessage and aMessage will be sent to all of someObject's delegates (for any value of aMessage). The only way I've been able to do this is something like: sendMessage:aMessage ...

How to implement Repository Pattern with interface, base and concrete.

I have almost completed implementing my repository pattern by having a IRepository<T> interface, a NewsRepository class and a News entity. The problem I ran into was trying to abstract out common methods to a base Repository class. I could not find a way to abstract the Get method in the NewsRepository as it contains a specific Linq ex...

what to use for php db abstraction layer?

Hi, I have been using Creole for a year, but Creole project is dead now.. what are other good abstractions for php ? ...

When should I return the Interface and when the concrete class?

Hello SO people, when programming in Java I practically always, just out of habit, write something like this: public List<String> foo() { return new ArrayList<String>(); } Most of the time without even thinking about it. Now, the question is: should I always specify the interface as the return type? Or is it advisable to use the ...

Can abstract thinking be taught?

I broke some of the cardinal rules for hiring and am now stuck with a fairly 'bad' hire. My biggest concern is that the person's abstract thinking is really weak. So, my question is do you guys think abstract thinking can be taught? And if so how? Or should I start preparing an exit strategy? I'm sure some of you guys have been caught ...

Too many layers of indirection, is this too many?

I was just wondering if this would be to many layers of indirection? I try and do a little bit of explaining, the idea is that I am building a API over the top of a COM object which only exposes Do and Eval methods. Previously I have just passed a IComObject into the Table class and work directly against that however that means when ...

Benefits to using a database table instead of just hard coding a simple list of data if the data is consumed by 1 app.

For a while, I've been told by a number of people that a listing of U.S. States (and territories) should be stored in a database table and cached for applications that use the information. The only reasons they give me for this is to promote normalization and because "it's how we've always done it". Now if the list changes often becaus...

.NET reflection/abstraction of HTML?

I'm curious about the possibility of having a .NET class library that provides a complete abstraction of HTML (and perhaps CSS styles as well). There would be a .NET class for every kind of HTML element, and even abstract classes (e.g. an abstract base class 'List', which 'OrderedList' and 'UnorderedList' extend). The elements could be...

Best Way to Abstract Initializing Attributes

What's the best way to abstract this pattern: class MyClass attr_accessor :foo, :bar def initialize(foo, bar) @foo, @bar = foo, bar end end A good solution should take superclasses into consideration and be able to handle still being able to have an initializer to do more things. Extra points for not sacrificing performance...

How would you hide the specific ORM implementation in: class Project < ActiveRecord::Base

Let's say I have a model class called Project, but instead of this: class Project < ActiveRecord::Base I wanted to write this: class Project < ORM so that the specific ORM implementation is not present in my model class. How would I need to write my ORM class so that the Project class above is able to act as a subclass of ActiveRe...

Generating urls form MVC Routes in a Management layer...

So... I have a business object/manager which is going to generate emails. These emails will contain links to various content on the website... and therefore needs to understand about MVC routing.. or at least how to generate URLs for the website... However my business object will not have access to a RequestContext etc and the email ge...

Exceptions and Abstractions

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 wor...

How can I reduce the redundancies in my jQuery code?

The size of my JavaScript file is getting out of hand because I have hundreds of links, and each one has its own jQuery function even though they all peform basically the same task. Here's a short excerpt: $("#link1").click(function () { $(".myDiv").hide(); $("#myDiv1").toggle(); }); $("#link2").click(function () { $(".myDiv").h...

How can future programming languages better facilitate abstraction?

One of the key properties to designing comprehensible software (and, indeed, designing anything at all) is to develop a good set of abstractions. These days, those abstractions include things like functions, classes, interfaces, recursion, and higher-order functions. But what else is there? How can we further abstract our designs, so tha...