350 likes | 472 Views
KEA September 22 2011. Real Life ASP.MVC. Christian Dalager, Eksponent ApS. Me. .NET developer, Eksponent ApS Lead on Arena365.com C#, Ruby, Java, PHP, Perl Background in Nordic Language and Literature + IT University. ASP.NET MVC. MVC a what??. Model View Controller design pattern
E N D
KEA September 22 2011 Real Life ASP.MVC Christian Dalager, Eksponent ApS
Me • .NET developer, Eksponent ApS • Lead on Arena365.com • C#, Ruby, Java, PHP, Perl • Background in Nordic Language and Literature+ IT University
MVC a what?? • Model View Controller design pattern • Separates data, presentation og logic
MVC parts • View • Webforms view engine <%= ”yay” %> • Alternatives: Razor (MVC3), Spark,Nhaml • Controller • Core framework • public class MyController: BaseController{} • Model • ... nothing...
The Missing M • No builtin database/persistence features • Lots of options • Entity Framework / linq2sql • NHibernate / Castle ActiveRecord • Subsonic • External services (WCF i.e) • Home made DataAccessLayer with SQL statements (sooo 2003)
Case Arena365
Arena365.com • Social tool for active lifestyle, for groups and individuals • Track your training, manage your teams • Google maps / Routes • Facebook Integration • Campaigns • 7.500 users
Arena365 Facebook, RSS, Maps, Twitter, GetSatisfaction, MailChimp. Console App Views JSON iCal XML CSV ViewModels Windows service CMS Controllers Service Service Service Repository Repository Repository Repository Database Cache NHibernate
Building blocks • DI Containers • Logging • Caching • Error reporting • Mail sending • Facebook integration • iCal feeds • Import routes • Import RSS • CMS functionality • Security/ACL • Build scripts • UnitTests • Source Control
Show me the code! • # lines of C# code (LOC) 17 157 • # lines of comment 4 010 • Percentage Comment 18% • # Assemblies 11 • # Namespaces 112 • # Types 1 185 • # Methods 7 658 • # Fields 3 284
Complex Systems are.. complex • Requirements change over time • Build for change • YAGNI (you aint gonna need it) • Pragmatism vs Idealism
http://www.iwaysoftware.com/solutions/by_integration/DataIntegrationSolutions.htmlhttp://www.iwaysoftware.com/solutions/by_integration/DataIntegrationSolutions.html
http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi?coll=linux&db=bks&fname=/SGI_EndUser/GC_Hdwr_UG/ch01.htmlhttp://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi?coll=linux&db=bks&fname=/SGI_EndUser/GC_Hdwr_UG/ch01.html
Hands-on Agenda • Skinny controllers • ViewModels • Dependency Injection • AutoMapper • ModelBinders
Architecture i MVC ASP.NET MVC Controller View Model
ArchitectureinMVC ASP.NET MVC Data / Business logic Controller Domain model View DB ViewModel
ViewModels • Flattenedclasses • Tailor made for views • Projections
Skinny Controllers • Keepyourmethods small • Keepyourdependencycountdown • Keepyour controllers skinny • Benefits • Reusability • Testability • The essentialsmayalwaysfityour screen
Ask Questions • How big is thisbeastgonnaget?! • How manyentities do you have? • How many controllers willyouneed? • How long do youexpectyourapp to live? • Are theremanystakeholdersthattogetherdefine the projectscope? • Will the projectchangedirectionsbeforeit’s done? (Funding will do this to you) • Is the project an exploratoryjourney or do youknowexactlywhereyouwill end? • How manyintegrationpoints do you have?
Thank you. I love you<3 • christian@eksponent.com • Blogdalager.com • Tweetstwitter.com/dalager • Source Code / Presentationbitbucket.org/dalager/ • Job?job.eksponent.com/