Adventures in ASP.NET MVC 2: Project initiation


I had a bit of downtime with my new position and figured I could focus on getting the 46mommas.com site up and running. As i am Microsoft oriented, it only made sense to use ASP.NET MVC 2. As I am a bleeding edge type of guy, I figured I would use parts of Enterprise Library 5 in the solution. I am mostly interested in seeing what has been done in Unity 2.0.

Initial Steps

First I had some software to download.

  • ASP.NET MVC 2.0
  • Enterprise Library 5.0 (could have opted for Unity 2.0 only, but if I am playing, I might as well play ;->)
    NOTE: If you want Unity for Silverlight, there is a download on the Unity download site for you
  • Possibly some other software, including:
    • Spring.NET – Although there are overlaps with Unity, so not sure on this one
    • jQuery – This is a given with ASP.NET MVC
    • Other?

Fortunately, the install process is fairly fast, so I am done in just a few minutes.

The Project

In September of 2010, my wife and 45 other women are going to shave their heads for childhood cancer awareness. The venue is not yet figured out, but theey are aiming for national television. This gives me some thought on features needed and desired.

  • Project information page
  • Information pages for each participant (who they are, why they are involved)
  • Ability to have media (movies, etc)
  • Some form of login for participants to add content
  • Press are for press releases, etc
  • Ability to see participants on a map (Google maps?)

I also wanted to create a short URL feature that jets a person to a page, so this is going to be my first experiment with ASP.NET MVC routes. So, routes is the next article in this series.

Other Notes

That pretty much does it for this particular post. I am already rolling on the project, so I will update with more articles over the next few days as I finish the original implementation.

Peace and Grace,
Greg

HR 4872 – The Health Care Reconciliation Bill (An Analysis)


I am frankly a bit pissed at my Representatives at this time. While I applaud the following of the letter of the law and posting the final text of the bill 72 hours before a vote, the vote is going to take place on Sunday, when none of us can call and voice our opinion. But I think that was by design. In addition, the final text is not really the final text, as it is reconciliation bill. This means you have to get this bill, along with the House, er Senate bill (As the Senate cannot enact legislation that adds taxes, they hijacked an Affordable Housing for military bill). Having to read amongst bills is a royal pain in the rear. In addition, the analysis of the bill on many sites has a different numbering scheme than what you can find on Thomas.loc.gov, which makes this even more confusing. I also believe that is intentional.

If you are interested in reading it yourself, you can look at the following:

For the record, this is a reconciliation bill, as it gets around filibuster rules. If they can get the votes, there is little that has to be done to get it passed. Note also that the Senate can reintroduce abortion provisions, etc, and only need 51% (or 50% plus 1 in House) to get it passed. I am not sure whether they would consider putting Blue Dogs out to dry in this manner, but it is a possibility. They need them now, but may not next week.

There are some good things in the bill, which may help some Americans, but the overall result is rising costs are not controlled, except through Medicare and Medicaid cost cutting provisions (which traditionally have been overridden by Congress to keep doctors happy). In addition, there are tons of new taxes in the bill.

Cost to America

The bill claims it will reduce the budget deficit by $138 billion from 2010 to 2019. But this figure has already been revised today (March 20) to $82.1 billion, almost $56 billion less savings than claimed just 3 days ago (March 17). There is a provision to stop the growth of tax credits past 2019, which suggests, to me, that the government knows that health care costs will continue to rise under their plan, as there are no provisions that guarantee lower health costs.

There is a provision to lower the cost of Medicare, but the actual decision on the funding is in another bill and can be changed or voted down. As the bulk of the savings are located in Medicare and Medicaid, there is no guarantee we will ever realize the budget deficit. Considering past actions, where the lowering of Medicare rates for doctors have not been enacted, there is no guarantee this bill will have any effect on the the cost of health care.

One should also note that taxes are enacted prior to the enactment of health care provisions in bill. This means the $82.1 billion deficit reduction (about $8 billion per year) includes 4 years of taxation prior to enactment of most provisions (the years 2010, 2011, 2012 and 2013). The amount of taxes raised during the first four years is estimated at $68 billion (other revenue provisions) plus $27 billion (effects on direct spending and other revenue provisions) for a net raised of $95 billion prior to enactment of the major health care provisions of the bill. If you consider a budget deficit of $82.1 billion. If you are not getting the picture yet, it is fairly simple. Starting in 2020, the jump start monies will not longer be in effect, and true yearly costs versus revenues will be realized. You should take this in account when you consider the tax credits to keep health care affordable are designed to cap out in 2019 if health care rises above the Consumer Price Index (CPI) and the actual costs are not more than 10% below the CBO budget estimates. In all likelihood, they will cap..

Employee and Employer Costs

From tax year 2013 on, you will only be able to sock away $2500 in your HSA or FSA. There is currently no max, other than the max set by your company. My current plan, for example, allows me to sock away $2500 for me and $5000 for my family. I would only be able to sock away 1/3rd of that in 2013.

Businesses are fined $2000 per FULL TIME employee (FTE) for not offering insurance. The first 30 employees are not counted in the calculation, however, so the fine for not having insurance for a company of 50 employees is $40,0000, or about what they currently pay on 4 employees. In businesses that do not have to offer insurance to remain competitive, this would be a major savings for the business and force you into a public pool. If we take that business with 50 employees, it stacks up like this:

                           2009           2014 if drops coverage     NET
EMPLOYER           $495,000     $20,000                            ($475,000)

The average employee pays around $3500 for premiums in 2009. Under the new plan, his premiums will cap at $4060, a $560 increase over current payments. This may still be lower than what he would pay in 2014 if costs continue to rise, but it also makes him a recipient of government assistance (welfare for the middle class?). There is also a max for cost sharing that is added on top of this. To get the credit, as a married couple, you must file jointly.

Taxes

Here are a list of new taxes:

  1. Investment dividends are no longer excluded for Medicare taxes, so all monies made on savings accounts, as well as other investments, will be taxed at 2.8% under the new plan. This only applies to individuals making $200k per year and families making more than $250k per year.
  2. .9% increase in Medicare taxes for
  3. Cadillac plan tax of 40% over threshold. This is delayed until 2018 and the plans are now set at $10,200 value for individuals and $27,500 for families.
  4. Can only put $2500 in an HSA after 2013 (a year before the health care provisions go into effect)
  5. 2.9% excise tax on all medical equipment, except common equipment purchased by individuals – This was originally a fee
  6. $4.8 billion per year fee on pharmaceuticals
  7. Elimination of deduction of Medicare Part D for individuals (delayed until 2013)
  8. Tax on tanning services – this one will not hit me, as I don’t use a tanning booth, but will hit average Americans

The current upper limit for taxes is 39% in the United States, under this bill it would rise to 43.4%, 6.6% less than 1/2 a person’s earnings. Think about that for a second. Sure it is only the “rich” that are getting soaked.

Student Loans

There are provisions in the Health Care Reform bill to alter the way student loans are procured and paid back. This makes perfect sense. If you take out the fact that student loans have nothing to do with health care and reform, they are the same issue.

My Feelings

There is still nothing in the bill that is guaranteed to lower the cost of health care. There are provisions to lower Medicare and Medicaid spending, but the actual vote on the reduction requires passing additional legislation. It also appears the government is planning for a rise in costs, as they have a stop gap measure in affordability credits in 2019 if the cost of health care rises above the CPI and the CBO estimates are correct (they have to be 10% less than estimates to not cap the credits).

Looking at the taxes on pharma, medical devices and health insurance providers, I expect the cost of health care to go up somewhere between 10% and 20% in the next few years, increasing costs for average Americans significantly. Then, in 2014, when the provisions enter, these Americans will be able to get some of the money back at the end of the year in the form of affordability credits. That is scary to me.

Middle class two-income families will likely see a huge sock when the bill goes into effect, as they can easily fall outside of the 400% above poverty level “get a credit” crowd. Many of these people are having problems making ends meet today.

I also see employers, especially small employers, having a great incentive to drop health care coverage and allow the worker to pick up insurance elsewhere. Admittedly, without pre-existing conditions, this will be much easier.

End the end, I see this bill as another “reward the irresponsible” bill, much like the interest rate reduction for homeowners who got themselves into too much home for their salary. It helps a few people, but it makes welfare recipients out of the middle class, through credits. And I see costs rising even steeper than they have risen over the past ten years.

What we need to do is get the middle man out of the mix, not embed a new middle man.

Peace and Grace,
Greg

Twitter: @gbworld

Paradigm Shifting: Rethinking ASP.NET MVC


NOTE: This is the first part in a series of notes for an upcoming book Paradigm Shifting: Rethinking Architecture and Development in .NET, Visual Studio 2010 Edition.

I recently read a book on ASP.NET MVC that had the following statements:

  • Model – An MVC Model contains all of the application’s logic that is not contained in a view or controller. The model includes all of an application’s validation logic, business logic and data access logic. The MVC model contains model classes that model objects in the application’s domain.
  • View – A view contains HTML markup and view logic.
  • Controller – A controller contains control-flow logic. An MVC controller interacts with MVC models and views to control the flow of application execution.

I have a problem with the statement about what a model is, as it goes far beyond what I find a model should be in a well design statement. To understand my issue with the statement about models, you need to understand what a domain is. I will try to do this in very simple terms.

The Domain and the Model

A domain is generally classified a “problem domain”. We have a “problem” that needs to be solved for business and we are “modeling” objects in this area, or “domain”. But that is a bit of an oversimplification.

Let’s look at a order as an model. Within the “problem domain” of a customer ordering items, an object model contains information about the various items the customer is ordering, including pricing information, payment information, a payment address (used primarily for authenticating a user), a mailing, or shipping, address, etc. When you move to the “problem domain” of shipping an order, however, you no longer need the payment information. In this domain, you need a pull list of items and shipping information. If you follow domain design properly, you will often create different objects to represent an order in different domains.

When you look at the last paragraph, the “model” of an order, when properly designed, contains information (data?) and not much more. To be a bit more geekish, the model contains “state”, which merely means it represents the object as it is during a certain point in time (when it is being interacting with, for example). I don’t have a problem with a model that also contains validation logic, although you can separate out that responsibility at times. There are samples of models that handle their own validation that do not break the rules of separation of concerns rule, but be careful how you handle validation and make sure it fits your feedback methodology.

The problem comes when you start introducing other types of logic in a model. There is a pattern called Active Record where the class contains methods to load (SELECT/READ), save (UPDATE and INSERT/CREATE) and destroy (DELETE). These methods are CRUD (CREATE, READ, UPDATE and DELETE) methods. I have also included the SQL keywords that correspond to CRUD in the sentence (SELECT, INSERT, UPDATE and DELETE). This pattern does not contain business logic, however.

When I examine applications from a few years ago, the Active Record pattern was very much in vogue. And this particular pattern is still popular, as an option, in some O/R Mapper projects. Subsonic comes to mind, but you also see Active Record in .NET Tiers and some others. When you examine sites today, however, the Active Record has largely fallen out of vogue and you see the Repository pattern being used.

The Repository pattern separates the data access logic from the domain model. You “feed” the model to the Repository, which is responsible for the save (INSERT/CREATE and UPDATE) and delete (DELETE) methods and the model only contains state. As stated before, I don’t see validation as a huge problem in these objects, as long as you ensure the validation logic fits your feedback methodology.

NOTE: If you want to learn more about Domain Driven Design, consider Eric Evans book Domain Driven Design: Tackling Complexity in the Heart of Software.

The View

I don’t have any problem with the View description, but understand that view logic is merely logic necessary to display the domain models to the user in a “view” (think of a view as “one way to view a model” and you see the reason for the name). In MVC, this user will be a human (at least in the instances that come to mind right now). Note, however, that you should be able to easily switch out view engines, which serves to muddy the waters (Silverlight, for example, can be used as a view). If you want to read one opinion on which view engine to use, you can look here or here or here.

The Controller

I also don’t have any problem with the description of a Controller. In a simple MVC application, the Controller simply marries the model with the View and ensures models changed by user interaction get sent back to the application. There are decent UI reasons to expand it beyond a simple minister model (ministers “marry” people), but many of the simpler samples do little more than facilitating this “marriage”.

Paradigm Shifting

Okay, so this brings us to a bit of a paradigm shift in thinking. When you think ASP.NET MVC, you probably don’t think of it as interacting with an application, but rather as the user interface part of an application. When I think of applications, I think of them pretty strictly as the business layer only. Here is my reasoning:

  1. You should be able to switch out the database without changing application logic. Most people find this to be an easy concept to get their heads around, as we have plenty of examples of applications that can work with multiple types of databases.
  2. You should be able to switch out the user interface without changing application logic. This is harder for many people to completely grasp, as they think of the UI as part of an application (3-tier or n-tier come to mind).

In my view (play on words?), ASP.NET MVC is one choice of user interface. Other types of UIs include Windows Forms, classic ASP, WCF services (or ASMX web services), WPF and Silverlight. This is not a complete list. And, many may disagree with WCF being a UI technology, as it presents information to another application or service rather than a human. If you agree with this grouping, we might define WCF, and all UI technologies for that matter, as boundary technologies, as they represent a boundary in an application. The more standard UI technologies, like ASP.NET MVC, end on a boundary that requires interaction through a front end; WCF ends on a boundary between “applications” or “services” in most instances. Taken to the extreme, as Juval Lowey does, WCF can be used for all boundaries. That is a topic a bit too involved for this discussion, however.

Here are a few guidelines I believe work with ASP.NET MVC. There will be exceptions where you step outside of the guidelines, of course (“rules are meant to be broken”?), but the guidelines serve to make for a better application in most cases;

  1. Models should represent objects in a particular domain.
  2. Models should contain state, not behavior.
  3. Models should not contain business logic. Unless a pattern like Active Record is used, they should not contain data access logic.
  4. Views should be concerned with presenting models to users, as handed off from the controller.
  5. Views should only contain logic necessary to present models. They should never contain application, or business, logic.
  6. Controllers should be concerned with controlling the flow of the user interface.
  7. Controllers should not contain business or data access logic.

We can make this more complex by getting into the subject of binders and actions, etc, but understand that the primary purpose of ASP.NET MVC is to act as the user interface for an application. I will hit a few more topics over the next few weeks, but I thought this one was a good place to start, as rethinking the definition of an application is a useful topic.

FINAL NOTE: For those who are wondering, the book in question is ASP.NET MVC Framework Unleashed by Stephen Walther. Despite having a problem with the statement mentioned at the top of the article (from page 16 of the book), the book does not weigh down the models with business logic. The main reason I “picked” on the book was it was a prime point to focus on what MVC is and how it relates to applications as a user interface technology. When I get through with reading the book, provided it continues to be as good as the first few chapters, I will give it a good amazon.com review. 😉

Peace and Grace,
Greg

Twitter: @gbworld – best way to see when other articles are posted