Programming

Study Notes for 70-486 - Developing ASP.NET MVC 4 Web Applications

0

After the 70-480 Programming HTML5 and CSS 3 Exam, I finally got around to taking 70-486 - Developing ASP.NET MVC 4 Web Applications which gets me 2/3 towards the destination for MCSD: Web Applications. Following are the set of notes I used along with MCT material which may help those preparing for the exam. The topic-by-topic breakdown is courtesy of a colleague and friend Frank Liao.

[link link link]

Design the Application Architecture

  • Plan the application layers.

    • This objective may include but is not limited to: plan data access; plan for separation of concerns; appropriate use of models, views, and controllers; choose between client-side and server side processing; design for scalability

  • Design a distributed application. [link]

    • This objective may include but is not limited to: design a hybrid application (on premise vs. off premise, including Windows Azure) [link link]; plan for session management in a distributed environment; plan web farms

  • Design and implement the Windows Azure role life cycle. [link link link link]

    • This objective may include but is not limited to: identify and implement Start, Run, and Stop events [link link];identify startup tasks (IIS configuration [app pool] [link], registry configuration [link], third-party tools [link]) [link]

  • Configure state management.

    • This objective may include but is not limited to: choose a state management mechanism (in-process and out of process state management, ViewState); plan for scalability; use cookies or local storage to maintain state; apply configuration settings in web.config file; implement sessionless state (for example, QueryString) [link]

  • Design a caching strategy.

    • This objective may include but is not limited to: implement page output caching (performance oriented); implement data caching; implement HTTP caching

  • Design and implement a Web Socket strategy. [link]

    • This objective may include but is not limited to: read and write string and binary data asynchronously (long-running data transfers); choose a connection loss strategy; decide a strategy for when to use Web Sockets

  • Design HTTP modules and handlers. [link link]

    • This objective may include but is not limited to: implement synchronous and asynchronous [link link] modules and handlers; choose between modules and handlers in IIS [link]

Design the User Experience

  • Apply the user interface design for a web application.

    • This objective may include but is not limited to: create and apply styles by using CSS; structure and lay out the user interface by using HTML; implement dynamic page content based on a design

  • Design and implement UI behavior.

    • This objective may include but is not limited to: implement client validation; use JavaScript and the DOM to control application behavior; extend objects by using prototypal inheritance; use AJAX to make partial page updates [link]; implement the UI by using JQuery

  • Compose the UI layout of an application.

    • This objective may include but is not limited to: implement partials for reuse in different areas of the application [link]; design and implement pages by using Razor templates (Razor view engine) [link link]; design layouts to provide visual structure; implement master/application pages [link]

  • Enhance application behavior and style based on browser feature detection. [link link link link]

    • This objective may include but is not limited to: detect browser features and capabilities; create a web application that runs across multiple browsers and mobile devices; enhance application behavior and style by using vendor-specific extensions, for example, CSS

  • Plan an adaptive UI layout.

    • This objective may include but is not limited to: plan for running applications in browsers on multiple devices (screen resolution, CSS, HTML); plan for mobile web applications [link]

Develop the User Experience

  • Plan for search engine optimization and accessibility.[link]

    • This objective may include but is not limited to: use analytical tools to parse HTML; view and evaluate conceptual structure by using plugs-in for browsers [link]; write semantic markup (HTML5 and ARIA) for accessibility, for example, screen readers [link link]

  • Plan and implement globalization and localization. [link link link link link]

    • This objective may include but is not limited to: plan a localization strategy; create and apply resources to UI including JavaScript resources; set cultures; create satellite resource assemblies

  • Design and implement MVC controllers and actions.

    • This objective may include but is not limited to: apply authorization attributes [link] and global filters [link link]; implement action behaviors [link link]; implement action results [link]; implement model binding [link]

  • Design and implement routes. [link link link link]

    • This objective may include but is not limited to: define a route to handle a URL pattern [link]; apply route constraints [link link]; ignore URL patterns [link]; add custom route parameters [link]; define areas [link]

  • Control application behavior by using MVC extensibility points.

    • This objective may include but is not limited to: implement MVC filters [link link] and controller factories [link link]; control application behavior by using action results [link link], viewengines [link], model binders [link], and route handlers [link]

  • Reduce network bandwidth.

    • This objective may include but is not limited to: bundle and minify scripts (CSS and JavaScript) [link link]; compress and decompress data (using gzip/deflate; storage) [link]; plan a content delivery network (CDN) strategy, for example, Windows Azure CDN [link]

Troubleshoot and Debug Web Applications

  • Prevent and troubleshoot runtime issues.

    • This objective may include but is not limited to: troubleshoot performance, security, and errors;implement tracing, logging (including using attributes for logging) [link], and debugging (including IntelliTrace) [link link]; enforce conditions by using code contracts [link link]; enable and configure health monitoring (including Performance Monitor) [link]

  • Design an exception handling strategy. [link link]

    • This objective may include but is not limited to: handle exceptions across multiple layers; display custom error pages using global.asax or creating your own HTTPHandler or set web.config attributes; handle first chance exceptions

  • Test a web application.

    • This objective may include but is not limited to: create and run unit tests, for example, use the Assert class, create mocks; create and run web tests

  • Debug a Windows Azure application.

    • This objective may include but is not limited to: collect diagnostic information by using Windows Azure Diagnostics API Implement on demand vs. scheduled; choose log types, for example, event logs, performance counters, and crash dumps [link]; debug a Windows Azure application by using IntelliTrace [link] and Remote Desktop Protocol (RDP) [link link]

Design and Implement Security

  • Configure authentication.

    • This objective may include but is not limited to: authenticate users; enforce authentication settings; choose between Windows [link], Forms [link link], and custom [link] authentication; manage user session by using cookies [link]; configure membership providers [link]; create custom membership providers [link]

  • Configure and apply authorization. [link]

    • This objective may include but is not limited to: create roles; authorize roles by using configuration; authorize roles programmatically ; create custom role providers [link link]; implement WCF service authorization [link link]

  • Design and implement claims-based authentication across federated identity stores. [link]

    • This objective may include but is not limited to: implement federated authentication by using Windows Azure Access Control Service [link]; create a custom security token by using Windows Identity Foundation [link]; handle token formats (for example, oAuth, OpenID, LiveID, and Facebook) for SAML and SWT tokens [link link link link]

  • Manage data integrity. [link]

    • This objective may include but is not limited to: apply encryption to application data [link]; apply encryption to the configuration sections of an application [link]; sign application data to prevent tampering [link]

  • Implement a secure site with ASP.NET. [link]

    • This objective may include but is not limited to: secure communication by applying SSL certificates; salt and hash passwords for storage [link link]; use HTML encoding to prevent cross-site scripting attacks (ANTI-XSS Library) [link link]; implement deferred validation [link] and handle unvalidated requests [link], for example, form, querystring, and URL [link]; prevent SQL injection attacks by parameterizing queries [link]; prevent cross-site request forgeries (XSRF) [link]

Share

Cloud Computing and CQRS Resources

MSDN Blogs: Cloud Architecture Series - CQRS Part 1 (Bruno Terkaly)

MSDN Magazine: CQRS on Windows Azure (Mark Seeman)
http://msdn.microsoft.com/en-us/magazine/gg983487.aspx

Book: Exploring CQRS and Event Sourcing: A journey into high scalability, availability, and maintainability with Windows Azure (MS Patterns & Practices)
http://www.amazon.com/Exploring-CQRS-Event-Sourcing-maintainability/dp/1621140164
And a few backgrounders:
CQRS - a new architecture precept based on segregation of commands and queries (Marco Heimeshoff, Philip Jander)
http://www.h-online.com/developer/features/CQRS-an-architecture-precept-based-on-segregation-of-commands-and-queries-1803276.html

CQRS Starting Page (Rinat Abdullin)
http://abdullin.com/cqrs/

The Best Way to Learn CQRS, DDD, and Event SOurcing (Rinat Abdullin)
http://abdullin.com/journal/2010/9/10/the-best-way-to-learn-cqrs-ddd-and-event-sourcing.html

MSDN: CQRS Journey Project
http://msdn.microsoft.com/en-us/library/jj554200

Slides: CQRS: Command/Query Responsibility Segregation
http://www.slideshare.net/brianritchie1/cqrs-command-query-responsibility-segregation

Slides: CQRS and Event Sourcing, An Alternative Architecture for DDD (Dennis Doomen)
http://www.slideshare.net/dennisdoomen/cqrs-and-event-sourcing-an-alternative-architecture-for-ddd

When to Avoid CQRS (Udi Dahan)
CQRS is Too Complicated (Rob Ashton)
"I think the main problem with DDD and CQRS is that they are misappropriately used.  The vast majority of systems do not  need this level of sophistication. What is more worrying is that .NET has adopted CQRS as their new and shinny. 
I shudder at people using either for CRUD but I suspect it does happen."
--Paul Cowan
courtesy of David Lazar
Share

Writing High Quality Code in C# by Svetlin Nakov

 

This is an excellent presentation by Svetlin Nakov of Telerik which I thoroughly enjoyed and decided to share it via my blog. Following is the abstract.

The author introduces the principles of high-quality programming code construction during the software development process. The quality of the code is discussed in its most important characteristics – correctness, readability and maintainability. The principles of construction of high-quality class hierarchies, classes and methods are explained. Two fundamental concepts – “loose coupling” and “strong cohesion” are defined and their effect on the construction of classes and subroutines is discussed. Some advices for correctly dealing with the variables and data are given, as well as directions for correct naming of the variables and the rest elements of the program. Best practices for organization of the logical programming constructs are explained. Attention is given also to the “refactoring” as a technique for improving the quality of the existing code. The principles of good formatting of the code are defined and explained. The concept of “self-documenting code” as a programming style is introduced.

Share

Enterprise Node Advocacy Talk

Node.js adaptability in a medium to large, regulated enterprise can be quite challenging; various process items including risk & compliance, OSS, supportability, static-code analysis, IDE/SC integration info-sec concerns etc need to be addressed before any new technology can be adapted.

My co-worker Daniel Imrie-Situnayake did a great presentation on this very topic titled "Within the Whale: a story of enterprise Node advocacy from the inside out". 

Share

WCF vs. ASP.NET Web API – An Architect’s Primer - Speaking to Southern California .NET Architecture Users Group

I will be speaking to the next Southern California .NET Architecture Users Group - IASA chapter meeting will be Thursday February 21, 2013 at Rancho Santiago Community College District, 2323 N. Broadway, Santa Ana.

Meeting starts at 7:00 pm, pizza and networking 6:30 pm. Abstract follows.

WCF vs. ASP.NET Web API – An Architect’s Primer

ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. The new ASP.NET Web API is a continuation of the previous WCF Web API projection. WCF was originally created to enable SOAP-based services and other related bindings. However, for simpler RESTful or RPCish services (think clients like jQuery) ASP.NET Web API is a good choice.

In this meeting we discuss what do you need to understand as an architect to implement your service oriented architecture using WCF or ASP.NET web API. With code samples, we will elaborate on WCF Web API’s transition to ASP.NET Web API and respective constructs such as Service vs. Web API controller, Operation vs. Action, URI templates vs ASP.NET Routing, Message handlers, Formatters and Operation handlers vs Filters, model binders. WebApi offers support for modern HTTP programming model with full support for ASP.NET Routing, content negotiation and custom formatters, model binding and validation, filters, query composition, is easy to unit test and offers improved Inversion of Control (IoC) via DependencyResolver.

You will walk away with a sample set of services that run on Silverlight, Windows Forms, WPF, Windows Phone and ASP.NET.

 

Downloads: Slides and Source

Share

Study Notes for 70-480 Programming HTML5 and CSS 3 Exam

Having recently taken 70-480 Programming HTML5 and CSS 3 Exam, I think these notes I made may help those preparing for the exam. The topic-by-topic breakdown is courtesy of a colleague and friend Frank Liao.

 

Implement and Manipulate Document Structures and Objects (24%)

  • Create the document structure. [link link]
    • This objective may include but is not limited to: structure the UI by using semantic markup, including for search engines and screen readers (Section [link], Article [link], Nav [link], Header [link], Footer [link], and Aside [link]); create a layout container in HTML
  • Write code that interacts with UI controls.
    • This objective may include but is not limited to: programmatically add and modify HTML elements [link link link]; implement media controls [link link]; implement HTML5 canvas [link link] and SVG graphics [link]
  • Apply styling to HTML elements programmatically. [link]
    • This objective may include but is not limited to: change the location of an element [link]; apply a transform [link link]; show and hide elements [link]
  • Implement HTML5 APIs.
    • This objective may include but is not limited to: implement storage APIs [link link], AppCache API [link link], and Geolocation API [link]
  • Establish the scope of objects and variables.
    • This objective may include but is not limited to: define the lifetime of variables [link]; keep objects out of the global namespace [link link]; use the “this” keyword to reference an object that fired an event [link]; scope variables locally and globally [link]
  • Create and implement objects and methods. [link link]
    • This objective may include but is not limited to: implement native objects [link];

Implement Program Flow (25%)

  • Implement program flow.
    • Iterate across collections and array items [link]; manage program decisions by using switch statements [link], if/then [link], and operators [link]; evaluate expressions [link]
  • Raise and handle an event.
    • This objective may include but is not limited to: handle common events exposed by DOM (OnBlur [link], OnFocus [link], OnClick [link]); declare and handle bubbled events [link]; handle an event by using an anonymous function [link]
  • Implement exception handling.
    • This objective may include but is not limited to: set and respond to error codes [link link]; throw an exception [link]; request for null checks [link]; implement try-catch-finally blocks [link]
  • Implement a callback.
    • This objective may include but is not limited to: receive messages from the HTML5 WebSocket API [link]; use JQuery to make an AJAX call [link]; wire up an event [link]; implement a callback by using anonymous functions; handle the “this” pointer
  • Create a web worker process. [link link]

Access and Secure Data (26%)

  • Validate user input by using HTML5 elements. [link]
  • Validate user input by using JavaScript.
    • This objective may include but is not limited to: evaluate a regular expression to validate the input format [link]; validate that you are getting the right kind of data type by using built-in functions [link]; prevent code injection
  • Consume data.
    • This objective may include but is not limited to: consume JSON [link] and XML [link] data; retrieve data by using web services; load data or get data from other sources by using XMLHTTPRequest [link]
  • Serialize, deserialize, and transmit data. [link]
    • This objective may include but is not limited to: binary data [link]; text data (JSON, XML) [link link link]; implement the JQuery serialize method [link]; Form.Submit [link]; parse data [link link link]; send data by using XMLHTTPRequest [link]; sanitize input by using URI/form encoding [link link]

Use CSS3 in Applications (25%)

  • Style HTML text properties.
    • apply styles to text appearance (color [link], bold [link], italics [link]); apply styles to text font (WOOF and @font-face, size, understudy fonts) [link]; apply styles to text alignment [link], spacing [link], and indentation [link]; apply styles to text hyphenation [link]; apply styles for a text drop shadow [link]
  • Style HTML box properties.
    • This objective may include but is not limited to: apply styles to alter appearance attributes (size [link link], border [link] and rounding border corners [link link], outline [link], padding [link], margin [link]); apply styles to alter graphic effects (transparency, opacity [link], background image [link], gradients [link], shadow [link], clipping [link link]); apply styles to establish and change an element’s position (static, relative, absolute, fixed) [link]
  • Create a flexible content layout.
    • This objective may include but is not limited to: implement a layout using a flexible box model [link]; implement a layout using multi-column [link]; implement a layout using position floating and exclusions [link]; implement a layout using grid alignment [link]; implement a layout using regions [link], grouping, and nesting [link]
  • Create an animated and adaptive UI.
  • Find elements by using CSS selectors and JQuery. [link]
    • pseudo-elements [link] and pseudo-classes [link]
  • Structure a CSS file by using CSS selectors. [link]
Share

Refactoring Code to a S.O.L.I.D. Foundation - Speaking @ IE.NET UG

Tonight I will be speaking to Inland Empire .NET users group talking about "Refactoring Code to a S.O.L.I.D. Foundation". Abstract and meeting info follows.

Abstract: SOLID is a mnemonic acronym coined by Robert C. Martin (aka Uncle Bob) referring to a collection of design principles of object-oriented programming and design. By using these principles, developers are much more likely to create a system that more maintainable and extensible. SOLID can be used to remove code smells by refactoring. In this session, you will learn about the following SOLID principles with code examples demonstrating the corresponding refactoring.

S - Single Responsibility Principle - An Object should have only one reason to change.
O - Open/Closed Principle - A software entity(module, library, routine) should be closed to any modification but be open to extension
L - Liskov Substitution Principle - Derived classes should be substitutable for the base classes
I - Interface Segregation Principle - Having more fine grained interfaces over fat interfaces
D - Dependency Inversion Principle - Depending on abstractions, not concrete implementations.

Downloads: SOLID Presentation - Inland Empire UG, LosTechies ebook and SOLID-Code Sample

For RSVP and directions, please click below.

SOLId

Share

Getting started with PyTools and Visual Studio 2012

Let's face it, Visual Studio is THE best IDE around. IntelliJ IDEA comes to a close second for Java and Eclipse, it's too generic of a base class. I have been using IDLE for python which is ok until you start missing all the modern IDE features. In continued evolution of Iron Python, Python Tools for Visual Studio was created by a few Python and OSS enthusiasts at Microsoft’s Developer Division.

PTVS is a free/OSS plugin that turns Visual Studio into a Python IDE. Its Editing, Intellisense, Profiling, Parallel Debug & Watch, Live Debug REPL, MPI & Cluster Computing and Refactoring capabilities are fairly neat. PTVS claims to support CPython, IronPython, Editing, Browsing, Intellisense, Debugging, Profiling, HPC Clusters, Multiple REPL’s, IPython, Django, and Cloud computing with Client Libraries for Windows, Linux and MacOS.

Among the best features beside being able to put a break point in the code and step through, is the capability to open an existing python library from the source.

Get your existing python library and you can get a .sln out of it in couple of minutes flat; it just works. I was able to get Dr. Szymon Jaroszewicz's belief networks library up and running in few minutes.

Once you have the solution, you can add additional libraries as part of search path.

 

to avoid getting exceptions

exceptions.ImportError occurred Message: No module named <module name>.

You can start a simple project which uses numpy with a simple start->new project. Numpy is great for performing calculation relying heavily on mathematical and numerical operations. Here I will be calculating an Eigen vector.

If you have never used it, numpy works natively with matrices and arrays, perform operations on them, find eigenvectors, compute integrals, solve differential equations.

Put couple of break points and push F11 and viola.

So this is a quick intro to Python tools for visual studio. For more in-depth review, check out Python Tools for Visual Studio on codeplex.

Happy coding.

Share

In Defense of Code Comments

I like to think that we all agree that effective commenting is important; Code Tells You How, Comments Tell You Why. Comments should say things about the code that the code can't say about itself — at the summary level or the intent level even with intention revealing names. An example by coding horror is

string = join('',reverse(split('',$string))); OR 
new string(input.ToCharArray().Reverse().ToArray());

The code above reverses your string, but how hard is it to put the comment

# Reverse the string

into your .pl file to clarify your intent?

Robert C Martin’s must read book Clean Code: A Handbook of Agile Software Craftsmanship  has an entire chapter of the book devoted to comments.  Uncle Bob puts it quite well

“Nothing can be quite so helpful as a well-placed comment.  Nothing can clutter up a module more than frivolous dogmatic comments.  Nothing can be quite so damaging as an old crufty comment that propagates lies and misinformation.”

For someone who has worked with both enterprise and open source repositories, importance of comments cannot be understated. BootStrap, Node, JQuery, DNN, GTK, VLC to Hadoop and NServiceBus, useful comments are necessary and ubiquitous. Indeeed, a wall of comments is not being promoted here but the comment

"// doing this because it fixes bug #####"

is not a smell – in fact it's essential. Yes, I am talking to you Mr uber-cool-technology-of-the-day-taxonomy-dev-other-people-code-is-crap; We can all learn something from Paul Lutus's zeal for simplicity. As abtruse goose would say

How about the following example

Configure.With()
//this overrides the NServiceBus default convention of IEvent
.DefiningEventsAs(t=> t.Namespace != null && t.Namespace.StartsWith("MyMessages"))

Sometimes, the other extreme is cited as

int x ; // Integer x

OR 
// Copy the string bob into fred making sure not to overflow the buffer.
strncpy(bob, fred,sizeof(bob));

which obviously are anecdotes to the contrary. Speaking of code comments during build process, stating that build systems should just be responsible for generating binaries defies ALM intents and the entire discipline of static code analysis.

In Code Complete, another one of my highly recommended texts, McConnel has a detailed philosophical discussion on “To code or not to code” which makes an excellent reading for a quiet afternoon but I won’t delve into dogmatic debates. Instead, I’d like to emphasize on the pragmatic inference that the discipline brought on by enforcing XML comments or comments in general keeps the uniform practice to enforce comments for less obvious pieces of codebase. By suppressing the XML comments, one essentially develops an atmosphere which discourages code comments in general.

DDD / Uncle Bob / SOLID / Eric Evans "KoolAid" or not, experience suggests that effective commenting is directly proportional to readability and maintainability while overzealous refactoring and class sprawl doesn't help.

Share

Refactoring Resources Extraordinaire

Ebook: 31 Days of Refactoring (Sean Chambers)

http://lostechies.com/wp-content/uploads/2011/03/31DaysRefactoring.pdf

http://www.lostechies.com/blogs/sean_chambers/archive/2009/07/31/31-days-of-refactoring.aspx

 

Presentation: Refactoring Tactics and Strategies

http://lens.cos.ufrj.br/sugarloafplop/2002/download/refactoring-tutorial.pdf

 

Site: SourceMaking’s Refactorings Catalog

http://sourcemaking.com/refactoring

 

Book: Refactoring: Improving the Design of Existing Code (Martin Fowler, Kent Beck, et. al.)

http://martinfowler.com/books/refactoring.html

 

Book: Refactoring To Patterns (Joshua Kerievsky)

http://www.industriallogic.com/xp/refactoring/

 

Site: Martin Fowler’s Refactorings Catalog

http://refactoring.com/catalog/index.html

 

Site: Sources of Refactorings

http://refactoring.com/sources.html

 

Selected SourceMaking.Com Refactorings Pages

 

Share
Go to Top