NEWS: Discount phentermine price What does phentermine look like: Generic viagra fast shipping Information about viagra How to discontinue the use of phentermine Lowest cost generic viagra Tramadol next day Free viagra Dangers of phentermine Cialis drug for impotence Low dose of viagra Tramadol 100mg Buy canada cialis Buy phentermine by cod Mexican pharmacies online+no precription xanax Xanax withdrawals Phentermine diet pills Shipping phentermine to florida, Order phentermine cod online Viagra maker! Viagra price online Phentermine discount Xanax online Lowest phentermine 37 5 prices? Allowed cialis tag viagra xhtml Reliable same or next day phentermine purchase online On line phentermine Best generic viagra Alprazolam xanax Online consultations and prescriptions phentermine! Phentermine sites that ship cash on delivery Physican's desk reference phentermine What does generic xanax look like Importing cialis from canada to us, Phentermine dangerous Generic viagra soft tab Phentermine hoodia diet pill Phentermine overnight delivery Herbal viagra alternative review Phentermine hydrochloride! Buy cheap domain onlineatspacecom xanax Buy viagra prescription online, Viagra investigator Order viagra buying viagra uk Phentermine no prescription required Xanax picture Fact phentermine diet pill Pharmacy online phentermine Cialis info Free sample herbal viagra Discount drug phentermine Prescription viagra written, Tramadol cheap Buy phentermine online Generic viagra cheap Bactrim phentermine: Phentermine pharmacies online Tramadol without a prescription Long term side effects of phentermine Viagra suppliers Cheap overnight phentermine Fioricet phentermine shipping Buy viagra in canada Generic cialis price Phentermine purchase Phentermine in florida Cialis generic online Free shipping with phentermine order? Viagra online order guide Xanax liver damage! Xanax in urine Diet pal pay phentermine pill Cialis mexico Order xanax cod Cheap quality viagra 180 tablet tramadol Xanax online pharmacy no prescription Phentermine no perscription required 30mg phentermine yellow Low price phentermine Cheapest xanax online Phentermine shipped to florida Tramadol drug test Cheapest place to buy phentermine online Buy generic viagra Cheap online order viagra Time released xanax Viagra tablets Free generic viagra samples Safe internet shopping generic viagraeng: Viagra sample pack Cheap generic viagra Free pack sample viagra Compare prices on phentermine? Phentermine free shipping 90 supply no delay Female spray viagra Phentermine online prescriptions Cheapest phentermine diet pill 150 tramadol Phentermine next day delivery Phentermine online pay with mastercard Generic cialis india? Viagra paypal france Phentermine prozac Xanax dosage Buy online viagra viagra Woman use viagra Buy cheap uk viagra Free online phentermine shipping Ordering 30mg phentermine Cialis lowest price Delivered phentermine Book buy online order viagra No perscription viagra Cialis experiences Cheapest phentermine 90 day order Viagra pills Phentermine no rx needed, Buy viagra now online Cheap viagra pills Cheap prices phentermine Viagra for woman? Cialis tadalafil Withdraw xanax Viagra buy viagra Phentermine ionamin? Viagra in woman Phentermine forum. Discount phentermine prescription Phentermine no prescription required Xanax withdrawel Phentermine cheap no prescription, Cialis co drug eli impotence lilly Cheap viagra uk Cialis new viagra Best price viagra. Phentermine testimonials Methadone xanax interaction Viagra drug Pfizer viagra Xanax without prescription 5 mg Compare generic viagra prices Cialis free sample Cash on delivery phentermine Online prescription viagra without Buy discount phentermine Viagra paypal france Xanax online pharmacy Cialis online sales Vitamin b12 1000 mcg phentermine and panic attacks Viagra cheap Herbal viagra alternatives Viagra price compare Taking viagra or levivia as a booster for cialis Low cost viagra Buy xanax cod Cialis western open: On line viagra Xanax 2 mg Viagra dose Phentermine low prices Filing income tax tramadol Tramadol avinza drug interaction Phentermine without a perscription Pharmacy phentermine affiliate Cheapest prescription viagra Buy discount phentermine Phentermine side effects dangers Buy cheapest viagra leukemia symptoms Natural viagra alternative Buy cialis Phentermine cheap Does phentermine work Low natural resources for the drug phentermine, Cheap diet online phentermine pill Recreational viagra Santa claus viagra jokes Discount drug phentermine? Prozac and phentermine Dangers of phentermine heart Phentermine versus meridia Phentermine resident sale virginia Phentermine mexican pharmacies online Symptom tramadol withdrawal Phentermine discount no prescription Generic viagra cialis levitra buy cheap! Xanax precriptions Phentermine vs phentrazine Line prescription viagra Us pharmacy phentermine: Long term effects of phentermine use Impotence picture pill viagra, Tramadol cash on delivery Generic viagra soft tabs Phentermine complications Viagra online no prescription Buy cheap phentermine 5 mg Black market viagra Adipex cheap phentermine Tramadol without perscription Buy xanax without a prescription Viagra vs levivia Information phentermine shortage: Natural viagra free samples 5 mg diet pills Phentermine raleigh Saturday delivery cheapest phentermine Genric viagra Phentermine 180 Phentermine meridia xenical review 2005 comment december leave viagra Phentermine compare prices Cialis story. Phentermine rankings Diet in phentermine pill uk Cialis pills Uk viagra body building from sports supplement Canada online pharmacy viagra Phentermine wholesale Phentermine effects Phentermine money order Buy xanax on line Amsterdam holland viagra Cialis and levitra Viagrafix? Viagra cialis comparison Viagra prescription drug Natural viagra alternative Snorting xanax: Free shipping on phentermine diet pills Cheap phentermine free consult. Diet pal pay phentermine pill Does phentermine speed up metabolism Alternative herbal review viagra Mail order viagra online Buy viagra prescription online Cialis drug prescription? Picture of generic xanax Diet online phentermine pill! Tramadol and online pharmacy Phentermine pictures. Buying phentermine without prescription Phentermine success story Adipex between difference phentermine Phentermine accepts cod! Cheap tramadol without prescription Viagra price list. Wholesale pfizer viagra 5 cheap Mivial valve prolapse viagra How long does phentermine stay in your system Buying viagra online uk Phentermine pillstore Phentermine prices Does phentermine interact with hydrocodone Cheap online order viagra Cheap phentermine canada! Viagra cialis levitra Phentermine prescriptions? Filling online prescription viagra Phentermine and fast shipping Levivia viagra vs Inform your doctor medication phentermine dose weight Is phentermine dangerous Ordering phentermine! Phentermine pharmacy cod Buy viagra 1! Buy locally viagra Buy online phentermine shipping Phentermine review Alternatives to viagra Viagra overdose Xanax effect Female sexual inhancer viagra spray No overnight prescription xanax Cheap online phentermine prescription Liquid cialis Information phentermine Smoking xanax Us phentermine Side effects from prozac and xanax How long does viagra last Xanax american express? Free phentermine Tramadol prescriptions Levitra vs cialis vs viagra Viagra alternative uk Uk viagra body building from sports supplement Effects of long term xanax use: Purchase viagra Buy cialis Cheap phentermine free shipping First viagra commercial network tv Xanax dosing Information viagra woman Phentermine online ordering Tramadol drug interactions Xanax mexico Phentermine international order Lowest price phentermine with free shipping Ativan re valium vs vs xanax: Phentermine faqs Viagra by mail: Can xanax cause frontal lobe dementia Canadian cialis Purchase phentermine online Tramadol hcl tab Viagra on line uk Cialis levitra better What happens when women take viagra Viagra and high blood pressure Viagra herbal alternative Phentermine diet plan Buy viagra uk Order viagra viagra online Best cialis price Online viagra Viagra free consultation Diet drug loss phentermine weight Online doctors perscriptions xanax steroids Phentermine ship to florida Phentermine cod Phentermine uses From generic india viagra Cod phentermine shipped Generic viagra canada Lethal dose xanax. Adipex p phentermine Purchase tramadol Tramadol cheap overnight inexpensive Buy viagra online get prescription Viagra sales uk Cialis levivia sales viagra Alprazolam xanax over night Genric viagra Phentermine pharmacies Viagra online shop: Xanax long term effects Viagra without a prescription. Cialis and pomegranate interaction Cheap tramadol cod free fedex. Xanax withdrawals Stopping xanax? Viagra information Viagra anxiety, Phentermine shipped to ky Viagra canada Viagra sale online Xanax detoxification

Ayende’s “IoC and Average Programmers”

Ayende and Eli, among several others, are having a little back and forth about testability and how that is impacted by design choices. Here’s some more background.

I think the question that Eli poses at the end of his post merits a little more attention. Here it is for simplicity’s sake

Quiz: Which is easier to maintain:

File.WriteAllText(filename, text);

or

using(TextWriter writer = IoC.Resolve<ifilewriterfactory>().Create(filename)) writer.Write(text);

The first approach represents maintainability while the second approach represents “testability” insofar as it has been constructed to allow the injection of stub or mock objects, while the first approach, using a sealed static method, cannot easily have its behavior modified at test execution time.

There are more differences to the two approaches than are generally being discussed, and I think it might be valuable to talk about them a little bit more.

Here’s a quick rundown of the differences.

The File class doesn’t provide deterministic disposability in the same way that the second example’s using statement does. So let’s remove the using statement from the second example.

The File class isn’t injecting any dependencies, so let’s remove the container resolution bit.

After those two steps, we’re left with this (I’ve named the concrete factory on my own):

FileWriterFactory.Create(filename).Write(text);

The signature is a little more verbose, but otherwise, we’re not dealing with a significantly different idiom here. I think it’s safe to say that the fundamental behavior of the two approaches are pretty similar.

Reducing the two approaches to the lowest common denominator reveals that the question itself may be spurious, or at least poorly framed. What value is there in comparing the testability or maintainability of two approaches that in both concrete and abstract terms fulfill two different sets of requirements?

In my opinion, the maintenance-based critique of the second approach as needless complexity is a straw man. You may as well ask whether it’s easier to maintain an algorithm that performs basic arithmetic or one that implements Runge-Kutta approximation of differential equations.

A more productive comparison of would involve setting out a couple of basic requirements and implementing them using dependency injection and without using it. In that case, we might see that the ability to automatically resolve dependencies against services such as authentication (of course we need permissions to write the file, right?) is actually a win in the long term.  But then again, we might not.

The example Eli gave of a development team implementing an unnecessary feature and then being burned by it down the road is a great cautionary tale about why good product management is important, but I am not convinced that it holds much water when it comes to a discussion about whether or not designing your code for testability is a good practice.

I think that framing the discussion to be more about whether or not your approach to designing applications takes into account that various types of software that are out there and what their expectations are in terms of lifecycle, staffing, and maintenance might help to better address the core issue here: is it ever acceptable to put the big guns away and just hack out something that works?

Comments (1)

A Basic Overview of A .NET Based Distributed System, Pt 2

In Part 1 I discussed the logical architecture of a distributed system. Part 2 is dedicated to the physical architecture.

Physical Application Architecture

There are two primary concerns with the physical architecture of a distributed system: reliability and scalability. These two concerns are often viewed as marketing-driven buzzwords, and in fact they are frequently used as such. In an attempt to clear up this ambiguity, I will provide definitions for them.

Reliability & Scalability

In order to be considered reliable, a system must be constructed so that a failure of one component of service does not impact the remaining services. Another way of thinking about reliability is as fault tolerance. If the Listing Manager component goes offline, the Listing Service component should not be adversely impacted.

In order to enhance the reliability of the system, MSMQ queues are used to spool units of work prior to processing. These queues are persistent and provide a level of safety that simple HTTP-based web service invocations can’t provide.

Additionally, each component runs in its own isolated environment. Whether these independent environments are virtual or physical is not important. The important part is that they are separate.

This brings us to scalability. Since each component of our application is isolated from the next, and the interactions are loosely coupled, it is possible for us to use standard load balancing and clustering techniques to scale the application horizontally. In the following diagram you can see what the physical architecture looks like initially, and one option for what it might look like in the future.

Physical Application Architecture

By replacing the single instance nodes with clusters, we can dramatically increase the number of transactions the system can process. If it becomes necessary in the future, the database cluster can be replicated to other instances and the entire system can be clustered.

In part 3, I’ll take a closer look at the design of one of the queue processors.

Comments

A Basic Overview of A .NET Based Distributed System, Pt 1

There are many reasons to implement an application as a distributed system, and it’s not a decision to be undertaken lightly. For the moment, let’s assume that this decision has already been made and that it was a good one. Subsequent installments of this series will address the decision making process itself.

Application Overview

The initial requirements for the distributed system calls for a front end web service that accepts data from end users. This web service will expose features for creating a user account on the system and for modifying that account. In addition, it will allow and end user to update account statistics. The fundamental purpose of this service is for people to be able to create an account, assign a set of keywords, and retrieve lists of items for sale on a wide range of e-commerce websites that match those keywords. When a list of items for sale is requested, an XML document is returned that includes the title of the item for sale, a brief description, the price, and a link to that item for sale on the e-commerce site it came from. The link will have been modified to include the system’s affiliate account id. The service will track how much money an account has earned via affiliate sales and manage these funds internally.

It is almost immediately evident that as this service becomes more popular, the volume of traffic handled by the front-end web service will increase. Since it’s important that this service scale, the application will be implemented as a distributed system. This means that the web service front end needs to operate independently from the back-end processes that manage account creation and update, obtain the data from the e-commerce sites, and credit user accounts for successful affiliate purchases.

Logical Application Architecture

The first step in our design process is to articulate a draft version of the logical application architecture. In order to accomplish this, we’ll need to break down the different functional behaviors into discrete units. The logical architecture will help us to divide responsibilities and establish both the method and the means of collaboration between the different components. For example, we’ll be able to determine what communications protocols are used internally by the application, whether the requests will be synchronous or asynchronous, and most importantly, by keeping scalability in mind, potential physical architectures will begin to emerge.

Here is an example of a draft logical application architecture.

Logical Application Architecture

One of the first to mention about this architecture is that it’s based on the Unit of Work pattern. Units of work originate from multiple points in the system, but each one is represented as an XML message that’s processed through MSMQ. Queue processors wait for these messages and operate on them as they arrive. The only task that isn’t processed through a queue is the fulfillment of a request for product listings. These listings are retrieved directly from the database. Some of the units of work are also initiated by scheduled jobs within each component, but we’ll overlook that complexity for the time being.

In the next installment, I’ll talk about the physical application architecture.

Comments

Using ‘using’ To Your Advantage

One of my favorite syntax structures in C# is the using statement. It’s simple, concise, and helpful. Here’s a quick usage guide.

You’re going strong, writing your application, and you get that feeling in the back of your mind that you might need to be thinking more about performance. You’re creating an object that’s a real heavyweight.

One of the first things you should think about in this scenario is whether or not this object is bound to a scarce physical resource such as an I/O stream, a file handle, or a database connection. If your object meets this description, verify that it implements IDisposable. This interface is the key to the using statement. Here’s how it works: any type that implements IDisposable must implement Dispose() with the intention of freeing any unmanaged resources that the type has referenced during its life cycle. The using statement creates a lexical shortcut by initiating a block scope around a group of code. In other words, using operates a lot like try...catch...finally. When execution leaves the scope of that using block, Dispose() is called. This guarantees that you’ve freed any finite resources that your program was referencing.

Comments