4. What are habits ?
“Excellence is an art won by training and habituation. We do
not act rightly because we have virtue or excellence, but we
rather have those because we have acted rightly. We are
what we repeatedly do. Excellence, then, is not an act but
a habit.”
- Aristotle
5. The 7 Habits
1. Be proactive
2. Begin with the end in mind
3. Put first things first
4. Think Win-Win
5. Seek first to understand, then to be understood
6. Synergize
7. Sharpen the saw
7. Habit 1: Be Proactive
OH: A leader is a person that does work when there is work to
be done
8. Habit 1: Be Proactive
Do some research
Bing or Google "ASP.NET MVC Best Practices"
9. Habit 1: Be Proactive
Top Findings:
1. Use HTTP Accept Verbs on Action Methods
2. Rid Controllers of all dependencies
3. Use strong-typed views instead of the ViewData Dictionary
with "Magic" string keys
4. Use an IoC container
5. Use view helper classes for conditional view logic
16. Habit 1: Be Proactive
Resources used in previous slide:
http://weblogs.asp.net/rashid
http://codeclimber.net.nz/
17. Habit 1: Be Proactive
Resources used in previous slide:
http://weblogs.asp.net/rashid
http://codeclimber.net.nz/
And, my own experiences
18. Habit 1: Be Proactive
Read up on ASP.NET MVC best practices
Subscribe to feeds
As you write apps, develop your own best practices
Share your experiences with the world
20. Habit 2: Begin with the end in mind
Organize your MVC project for maintenance and deployment
21. Habit 2: Begin with the end in mind
Organize your MVC project for maintenance and deployment
Project Root (Solution Folder)
Lib - to hold dependencies
MVC Project
Unit Tests folder - to hold Unit Test projects
Other auxiliary folders...
23. Habit 3 - Put First Things First
Question:
Do you know what your database will look like in three months?
24. Habit 3 - Put First Things First
Question:
Do you know what changes your PM will be stressing you out
to deliver next month?
25. Habit 3 - Put First Things First
Make your database schema migration strategy a priority
26. Habit 3 - Put First Things First
Make your database schema migration strategy a priority
Explore alternative storage methods
Object DBs like db4o
Schema-less storage like MongoDB
For RDBMS, plan to alter your schema as your application
changes
Use a tool like Migrator.Net (my suggestion)
Use another method like managed SQL scripts
29. Habit 4 - Think Win-Win
Develop with two audiences in mind: end users and
developers. Then, create wins for each of them.
30. Habit 4 - Think Win-Win
Typical end user wants:
1. Intuitive interface, not necessarily beautiful
31. Habit 4 - Think Win-Win
Typical end user wants:
1. Intuitive interface, not necessarily beautiful
32. Habit 4 - Think Win-Win
Typical end user wants:
1. Intuitive interface, not necessarily beautiful
2. A responsive application rather than a fast application
33. Habit 4 - Think Win-Win
Typical end user wants:
1. Intuitive interface, not necessarily beautiful
2. A responsive application rather than a fast application
How to give them what they want:
1. Add Javascript, CSS, and HTML to your toolbox
35. Habit 4 - Think Win-Win
Typical developer wants:
1. Latest and greatest emerging technology
2. Clean code, not perfect code - an opportunity to
contribute/refactor
36. Habit 4 - Think Win-Win
"In everything...uniformity is undesirable. Leaving
something incomplete makes it interesting, and gives one
the feeling that there is room for growth...
Even when building the imperial palace, they always leave
one place unfinished."
- Japanese Essays to Idleness
14th Century (via Marcus du Sautoy on TED.com)
37. Habit 4 - Think Win-Win
Typical developer wants:
1. Latest and greatest emerging technology
2. Clean code, not perfect code - an opportunity to
contribute/refactor
How to give them what they want:
1. See Habit #1 (Be Proactive)
2. Write SOLID code
38. Habit 4 - Think Win-Win
Single Responsibility Principle
a class should have only one reason to change
Open/Closed Principle
a class should be open to extension, but closed to modification
Liskov's Substitution Principle
using a derived class in place of a base class should offer no
surprises
Interface Segregation Principle
use fine-grained interfaces specific to the client
Dependency of Inversion Principle
depend on abstract objects instead of concrete objects
40. Seek first to understand, and
then to be understood
Habit #5
41. Habit 5 - Seek first to understand, and
then to be understood
I'm listening...
42. Habit 5 - Seek first to understand, and
then to be understood
"How do I use the gridview control or the [some other ASP.NET
2.0 user control] in my view pages if I don't use code-behind
classes or viewstate" - An ASP.NET developer transitioning
from ASP.NET to MVC
43. Habit 5 - Seek first to understand, and
then to be understood
"How do I use the gridview control or the [some other ASP.NET
2.0 user control] in my view pages if I don't use code-behind
classes or viewstate" - An ASP.NET developer transitioning
from ASP.NET to MVC
"You don't" - Me
44. Habit 5 - Seek first to understand, and
then to be understood
"How do I use the gridview control or the [some other ASP.NET
2.0 user control] in my view pages if I don't use code-behind
classes or viewstate" - An ASP.NET developer transitioning
from ASP.NET to MVC
"You don't" - Me
"Then, how do I implement some kind of view component that
can be reused across my application for consistency and
maintainability?" - AADTFATM
45. Habit 5 - Seek first to understand, and
then to be understood
"How do I use the gridview control or the [some other ASP.NET
2.0 user control] in my view pages if I don't use code-behind
classes or viewstate" - An ASP.NET developer transitioning
from ASP.NET to MVC
"You don't" - Me
"Then, how do I implement some kind of view component that
can be reused across my application for consistency and
maintainability?" - AADTFATM
"Ah, I understand your concerns. And, I have an answer for
you" - Me
46. Habit 5 - Seek first to understand, and
then to be understood
Html Helpers
When elements of the view contain conditional logic
Partial views
For common view elements that can be reused arbitrarily
Spark View Engine
In case you can't shake the urge to use code-behind
classes in your Webforms or you just want to use an
awesomer view engine
48. Habit 6 - Synergize
Take separate parts and make them work together in a way
that the whole is greater than the sum of the individual parts
49. Habit 6 - Synergize
Take separate parts and make them work together in a way
that the whole is greater than the sum of the individual parts
How?
Separate your concerns
Controllers should ask views to display data, not tell
them how
View-Models are not domain-models
DRY (Don't Repeat Yourself)
Make it so components will need each other in order to
do more
Once your components are independent, make them
interdependent
51. Habit 7 - Sharpen the Saw
"There is no substitute for experience" - Proverb
52. Habit 7 - Sharpen the Saw
"There is no substitute for experience" - Proverb
Some Resources:
http://weblogs.asp.net/rashid
http://codeclimber.net.nz/
http://www.dimecasts.net
http://www.tekpub.com/
http://haacked.com/
http://blog.wekeroad.com
http://weblogs.asp.net/scottgu/