Wednesday, December 10, 2014

Location of MVC Assemblies


MVC 5
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Stack 5\Packages\ Microsoft.AspNet.Mvc.5.0.0\lib\net45\System.Web.Mvc.dll
MVC 4
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies\System.Web.Mvc.dll
MVC 3
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll
MVC 2
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 2\Assemblies\System.Web.Mvc.dll

Monday, December 1, 2014

Lambda hate, Lambda expressions suck?

From a Microsoft employee in 2005:
C# 3.0: Lambda expressions. I don't like it that much....
http://blogs.msdn.com/b/abhinaba/archive/2005/09/17/469568.aspx



From 2008, regarding Jon Skeet's book's love for them, with reply by Skeet:
Lambda expressions: Dangerous Madness
http://bytes.com/topic/c-sharp/answers/829866-lambda-expressions-dangerous-madness



From 2010 on StackExchange, upvoted 33 times:
Does the usage of LINQ and Lambda Expressions lead to less readable code?
http://programmers.stackexchange.com/questions/24940/does-the-usage-of-linq-and-lambda-expressions-lead-to-less-readable-code


https://www.google.com/search?q=lambda+expressions+suck&oq=lambda+expressions+suck



http://www.google.com/trends/explore#q=Lambda%20Expressions

July 2007 is when it hit big, but seems to have hit India before the US, which doesn't spike until January 2008.



===================
The first one, from 2005, at one point says these gems:

Why I don't like lambda expression in C#
C# has originally developed from C++ /Java and is (was :^) ) a strongly typed object-oriented language. The new features being introduced like closure, continuation (yes, yes very limited continuation) in C#2.0 and now type inference, lambda expressions are de-generating the language. Even though there are people go gaga aboutcontinuation and lexical closures these are fundamentally functional language features and should be left to that. Introduction of bits and pieces of functional language features are not going to add value to C# and at the same time the surface area of C# is growing beyond what most developer can grasp.
Every language has a domain of application and an audience. Most people who work in C# developing web-services and web-based applications today are not necessary computer science grads. For them these concepts are a huge variation from the way C# used to behave. Functional programming is for the academia and not from the industry and should be left as such.
If I am asked, whether I'll use these language features, my answer will be maybe, and that is because the code written by me will be reviewed and maintained by people in MS who are fairly conversant with these. However, I think these features add burden to the learning curve of people who are not super interested in C# and should be avoided in favor of easier language constructs’ that might take couple of lines of code more, but would be more readable and maintainable.
These are just my opinions and I'm sure the designers of C# had given a lot of thought before adding them, but I strongly feel that these features are just adding more surface area to the language and will mostly go unused by the masses.


Some comments were like this:

" I think your comments about keeping C# "easy" so the web monkeys can understand it are off base. That's why we have VB.NET. 

Keep VB simple and leave C# to the real developers."



#
I think it's funny how all these C# programmers like to look down on VB.NET programmers because they're Morts, but give them something that isn't absolutely trivial to understand, then all of the sudden they're becoming incredibly uncomfortable with the notion that they're just Morts that like curly braces.
Suck it up and learn how to use it.  It's going to become part of C#.  Or admit that you're just a Mort that likes curly braces.


#
Wow, this post is so old, yet still going!
My take is you can't just take one of the C# (1.0, 2.0, 3.0, etc) language feature and dice them up like this.
If you go beyond the vertical examination of the language as a computer scientist, and you apply those concepts horizontally as an architect or developer, you will see how the lattice is interwoven.
Pete, please don't give us the non academic and business semantics crap. Non academics are usually the ones writing the business efficient pragmatic code that makes it to production.
As for wasting business dollars on IT, blame the business men hiring the cheapest IT staff, not staffing an architect, and pushing through without a plan. The choice of language is hardly ever the cause of software project failures.
It's usually the business nerds coming up with arbitrary Gantt charts that screw things up before the first line of code is ever written. If you have a time and cost schedule before you have a team and a platform, your project is failed already.
Back to Lambda expression, they solve a very real need in both the business and development worlds, to express problems with the least possible syntactic pollution.
If the developer can't figure out the problem expressed in Lambda, then the only part they can figure out in an alternative syntax is that very syntax. The problem expressed will be obscured and even less understood by the developer. This goes back to the business nerds hiring idiots that code for cheaper.



  • #
    "My opinion is, lambda expressions will come as a shock to the community, yes. but they'll soon get over it and start to love it."

    I think you are overestimating 87.9% of .Net developers.  Don't forget, many of these guys are the same ones that started out with VBScript+ASP only 5-6 years ago with no background in mathematics, computer science, or engineering and no desire to "learn" a programming language.  And now you are expecting them to learn about relatively high level and abstract (again, relative) language constructs??

    Not going to happen.  As snazzy as the feature is, I think it'll go unused by the majority of existing .Net developers.



  • #
    Good discussion. My complements go out to abhinaba, the author, for his willingness to criticize a major language feature and spark such an interesting interchange.
    My gut reaction is to side with him. Like many other folks have said, different languages have different 'essences.' The essence of C# I think was to make the Microsoft version of Java (which was stealing so many developers) and throw in some C++ syntax to make that crowd happy. If that is true, then I would argue that abhinaba is correct, as the driving purpose of Java was to create a language which was an elegant interpretation of OO that fit business needs. The addition of features that allow C# to be a one size fits all language detracts from this paradigm.
    In the words of the President of the Federation of planets circa Star Trek VI, (approximately) "let us redefine progress such that just because we can do such a thing does not mean that we must do such a thing."
  • #
    Now here we are in 2010.  I transferred from a Java project to a .NET project last year, and I have to admit that lambda expressions have been one of the best things for us.  It's true that the people where I work are all smart folks, so I guess maybe lesser engineers might get confused, but I really don't think it's that confusing.  It took me all of maybe several seconds the first time I saw lambda notation to figure out what ".ToDictionary(x => x.Key)" does, and it only took a few seconds more to realize that it saves me about four lines of repetitive code to maintain.
    Of course nowadays it's clear that lambda expressions, besides being a good idea in and of themselves, were also a necessary building block in order to introduce LINQ.  In the months since our .NET project began, we have been able to leverage lambda expressions, LINQ, and expression trees generally to create an architecture that is far more flexible and easier to maintain than it would have otherwise had to be.
    Performance-wise, any hit we take due to the necessity of building expression trees and such is more than compensated for by our ability, using LINQ to Entities, to dynamically generate queries that produce all the data (and only the data) we want, in a single database round trip.
    Could the same functionality have been implemented in Java?  Yes, technically, but not practically.  Because we live in a practical world, time saved on writing and maintaining code takes something that was always "technically" possible and actually makes it available to you in real life.
    Maybe I just have the advantage of retrospection. I don't know what I would have felt if I'd been programming in C# for years and lambda functions were just getting introduced.  But looking back, I'm sure glad they were!
    And, by the way, I would argue that C# is still STRONGLY typed: It just doesn't always have to be EXPLICITLY typed.  The var keyword gives us the advantage of compile-time sanity checks without requiring us to be overly repetitive ("Dog dog = new Dog()") or unnecessarily verbose ("Expression<Func<Dog, bool>> dogCriterion = ...").
  • #
    Now we are in 2010. I have 20 years programming experience and I do use lamda expression but in 90% of the cases those projects are nightmare to support. The problem is you simply cannot find qualified programmers that do understand code complexity. Anybody can develop complex code. The problem is when you need to maintain that code later. So from business point of view all this "improvements" are pointless. The fact we have this long thread is the proof. Making something anonymous and closure automated is not help at ALL from maintainability point of view. And from business point of view I've seen this types of programming:
    1. Simple code complexity with many lines of code - that is the most usual case, you still can maintain it.
    2. Complex code meaning (like lamda, can be understand by 10% of the folks on the field) with less lines of code - that is the worst case.
    3. Simple code meaning (can be undertsand by ANYBODY) with less lines of code - that is the best case scenario, I can write this one ;-)
    Good software programming is reducing the complexity on ALL levels. Introducing language features that increase complexity (language surface) is a pure nonsense and the sooner Microsoft realize it the better. The whole idea of having .NET framework is about making the basis of the future programming more simple by shielding the language from the implementation, which contradicts this idea with making the language overly complex.
    That is my 2 pence form the real life projects.
    cheers
    Valko



Another good read:

Wednesday, November 26, 2014

MVC 4 project templates

MVC 4
Wednesday, November 26, 2014
8:47 PM
Not these project templates…..
Machine generated alternative text: Recent
Installed
Templates
D Visual Basic
A Visual C#
Windows
Web
D Office
Cloud
Reporting
D SharePoint
Silverlight
Test
WCF
Workflow
D Visual C++
D Visual F#
SQL Server
D Telerik
HDlnsight
LightSwitch
D OtherProjectTypes
Mnrlelinn Prniertc
Online
ame:
cation:
lution name:
.NETFramework4.5 Sortby. Default
ASP.NET Empty Web Application
ASP.NET Web Forms Application
ASP.NET MVC 3 Web Application
ASP.NET MVC 4 Web Application
C t:
EJ Telerik MVC Web Application
ASP.NET Dynamic Data Entities Web Application
ASP.NET AJAX Server Control
ASP.NET AJAX Server Control Extender
ASP.NET Server Control
Telerik Data Access Dynamic Data Application
Telerik Data Access Web Application
MvcApplication3
c:\users\hcovitz\documents\visual studio 2012\Projects
MvcApplication3
-
Visual C#
Visual C#
Visual C#
Visual C#
Visual C#
Visual C#
Visual C#
Visual C#
Visual C#
Visual CS
Visual CS
Search Installed Templates (Ctrl+E
Type: Visual CS
A project for creating an applical
ASP.NET MVC 4 and Web API
— Browse... j
Create directory for solution
...but the next step, THESE project templates:
Machine generated alternative text: New ASP.NET MVC 4 Project [][]
Project Template
Select a template: Description:
[ c; c; . A default ASP.NET MVC 4 project with an
account controller that uses forms
- authentication.
Empty Basic Internet Intranet
Application Application
Ct C Q’
e_i e_i ej e_J
Mobile Web API Single Page Facebook E
Application Application Application
Ct
e—J
Telerik MVC
Web Appli...
View engine:
[Razor “I
EJ Create a unit test project
Test project name:
MvcApplicationTMP.Tests
Test framework:
Visual Studio Unit Test Additional Info
j OK ] [ Cancel j
Screen clipping taken: 11/26/2014 8:32 PM
Empty
Wednesday, November 26, 2014
8:45 PM
Machine generated alternative text: New ASP.NET MVC 4 Project
Project Template
Select a template:
ri
Mobile
Application
o-J
Telerik MVC
Web Appli...
View engine:
[Razor
Description:
s
Create a unit test project
Test project name:
MvcApplicationTMP.Tests
Test framework:
[Visual Studio Unit Test
Additional Info
[ 0K j [ Cancel j
o-J
Empty
o-J
Basic
o-J
Internet
Application
ri
Single Page
Application
An empty ASP.NET MVC 4 project.
o_-J
Web API
ri
Intranet
Application
ri
Facebook
Application
vj
Screen clipping taken: 11/26/2014 8:46 PM
Machine generated alternative text: MvcApplicationTMP - Microsoft Visual Studio (Administrator) LluICI( Launch (LtrI+UJ ¿J L_. 
EDIT VIEW TELERIK PROJECT BUILD DEBUG TEAM SQL TOOLS TEST ARCHITECTURE ANALYZE WINDOW HELP
O1hI6? )—c. InternetExplorer—š9 Debug — . Subrnit—_
F Solution Explorer
Search Solution Explorer (Ctrl+;)
Solution MvcApplicationTMP (1 project)
A  MvcApphcationTMP
L’ fr Properties
L’ •-• References
• App_Data
A  App_Start
L’ C FilterConfig.cs
L’ C” RouteConfig.cs
L’ C” WebApiConfig.cs
• Controllers
• Models
A Views
4J Web.config
L’ 9 Global,asax
packagesconfig
L’ a Web.config
Screen clipping taken: 11/26/2014 8:46 PM
Basic
Wednesday, November 26, 2014
8:40 PM
Machine generated alternative text: New ASP.NET MVC 4 Project
Project Template
L1 Create a unittest project
Test project name:
MvcApplicationTMP.Tests
zJ Additional Info
OK J [ Cancel
Select a template:
ri ri
Empty Basic
Description:
A basic ASP.NET MVC 4 project.
o-j
Web API
o—j
Intranet
Application
o—j
Facebook
Application
A
o—j
Mobile
Application
ri
Telerik MVC
Web Appli...
View engine:
ri
Internet
Application
o—j
Single Page
Application
‘r
Razor
‘r
Test framework:
[sual Studio Unit Test
Screen clipping taken: 11/26/2014 8:40 PM
Machine generated alternative text: Dl MvcApplicationTMP - Microsoft Visual Studio (Administrator) Quick Launch (Ctrl+Q) p  X
FILE EDIT VIEW TELERIK PROJECT BUILD DEBUG TEAM SQL TOOLS TEST ARCHITECTURE ANALYZE WINDOW HELP
Internet Explorer e D Debug . ß . ! Submit
‘Solution Explorer
OC ‘o
Search Solution Explorer (Ctrl÷;) p
Solution ‘MvcApplicationTMP (1 project)
A  MvcApplkationTMP
L> . Properties
L> •-• References
• App_Data
I App_Staft
L> C BundleConfig.cs
L> CU FilterConfig.cs
fr CU RouteConfig.cs
L> CU WebApiConfig.cs
L> • Content
• Controllers
• Models
L> • Scripts
A J Views
L> • Shared
E@] _ViewStart.cshtml
Webconfig
L> ¿) Global.asax
Q packages.config
L> Q Web.config
Screen clipping taken: 11/26/2014 8:42 PM
Machine generated alternative text: ________________________________ ________________ P   X Theresourcecannotbefo... xl
Server Error in 7’ Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed. had its name changed, or is temporarily unavailable. Please review the following URL and make
Requested URL: I
Version Information: Microsoft NET Framework Version:4.0.3031 9; ASP.NET Version:4.0.30319.1 8067
Access is denied.
Screen clipping taken: 11/26/2014 8:43 PM
Internet Application
Wednesday, November 26, 2014
8:20 PM
Machine generated alternative text: New ASP.NET MVC 4 Project [][]
Project Template
Select a template: Description:
[ c; c; . A default ASP.NET MVC 4 project with an
account controller that uses forms
- authentication.
Empty Basic Internet Intranet
Application Application
Ct C Q’
e_i e_i ej e_J
Mobile Web API Single Page Facebook E
Application Application Application
Ct
e—J
Telerik MVC
Web Appli...
View engine:
[Razor “I
EJ Create a unit test project
Test project name:
MvcApplicationTMP.Tests
Test framework:
Visual Studio Unit Test Additional Info
j OK ] [ Cancel j
Screen clipping taken: 11/26/2014 8:32 PM
Machine generated alternative text: Register Log in
Home About Contact
.. .
ETMVCafcio)
s, and samples to help you get the most from
After you run it and Register a user, creates db.
Machine generated alternative text: 1 Solution NHLSPstraw’ (1 project)
A  NHISPstraw
L’ fr Properties
L’ •-• References
A  App_Data
n aspnet-NHLSPstraw-20141126201745.mdf
A  App_Start
fr C” AuthConfig.cs
fr C” BundleConfig.cs
k r.. r:i.r
Screen clipping taken: 11/26/2014 8:24 PM
Intranet Application
Wednesday, November 26, 2014
8:35 PM
Machine generated alternative text: New ASP.NET MVC 4 Project L
Proj cd Template
Select a template: - - Description:
A default ASP.NET MVC 4 project that
fl uses Windows authentication or Windows
. Azure authentication.
Empty Basic Internet Intranet
Application Application
ca
e—’ e—J e- e-
Mobile Web API Single Page Facebook
Application Application Application
e-
Telerik MVC
Web Appli...
View engine:
Razor
I Createaunittest project
Test project name:
MvcApplicationTMP.Tests
Test framework:
[Visual Studio Unit Test Additional Info
Screen clipping taken: 11/26/2014 8:36 PM
Machine generated alternative text: cq MvcApplicationTMP - Microsoft Visual Studio (Administrator) Quick Launch (Ctrl÷Q) ¿J — 0 X
FILE EDIT VIEW TELERIK PROJECT BUILD DEBUG TEAM SQL TOOLS TEST ARCHITECTURE ANALYZE WINDOW HELP
QeO ejhIi 9_ÇÍe InternetExplorereD Debug e I ‘•4’d>_ e Submit—..
Solution Explorer _________
- V #QdiHÌ
a
Otherwise, to use this template with Windows authentication, refer to the instructions below:
Hosting on 115 Express:
1. Click on your project in the Solution Explorer to select the project.
2. If the Properties pane is not open, open it (F4).  Properties
3. In the Properties pane for your project: •-• References
a) Set “Anonymous Authentication” to “Disabled”. • App_Data
b) Set “Windows Authentication” to “Enabled”. A  App_Start
L> Ct BundleConfig.cs
Hosting on IlS 7 or later: L> O’ FilterConfig.cs
1. Open IlS Manager and navigate to your website. > 0’ RouteConfig.cs
2. In Features View, double-click Authentication.
3. On the Authentication page, select Windows authentication. If Windows L’ 0’ WebApiConfig.cs
L’ • Content
authentication is not an option, you’ll need to make sure Windows authentication
is installed on the server. A  Controllers
L> C’ HomeController.cs
To enable Windows authentication on Windows: > • Images
a) In Control Panel open “Programs and Features”. • Models
b) Select “Turn Windows features on or off”. > • Scripts
c) Navigate to Internet Information Services > World Wide Web Services > Security A  Views
and make sure the Windows authentication node is checked.
> • Home
To enable Windows authentication on Windows Server: >  Shared
a) In Server Manager, select Web Server (IlS) and click Add Role Services. [@] _ViewStart,cshtml
b) Navigate to Web Server > Security Q Web.config
and make sure the Windows authentication node is checked. D faviconico
> ¿ Global.asax
4. In the Actions pane, click Enable to use Windows authentication. Q packages.config
5. On the Authentication page, select Anonymous authentication. D readme.txt
6. In the Actions pane, click Disable to disable anonymous authentication.
> Q Webconfig
template with Windows Azure authentication,
Screen clipping taken: 11/26/2014 8:52 PM
Machine generated alternative text: nttr: localhost:16286/ .0  C X I Access is denied.
Server Error in ‘I’ Application.
Access is denied.
Description: An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL.
Error message 401.2.: Unauthorized: Logon failed due to server configuration. Verify that you have permission to view this directory or page based on the credentials you supplied and the a
the Web server’s administrator for additional assistance.
Version Information: Microsoft .NET Framework Version:4.O.30319; ASP.NET Version:4.O.30319.1 8067
Access is denied.
Screen clipping taken: 11/26/2014 8:53 PM

Created with Microsoft OneNote 2010
One place for all your notes and information

Tuesday, November 25, 2014

Sure, throw a null-coalescing operator into an intro tutorial on MVC EF


"
int pageSize = 3;
int pageNumber = (page ?? 1);
return View(students.ToPagedList(pageNumber, pageSize));
The ToPagedList method takes a page number. The two question marks represent the null-coalescing operator. The null-coalescing operator defines a default value for a nullable type; the expression (page ?? 1) means return the value of page if it has a value, or return 1 if page is null.
"

Can't be surprised since he loves the Ternary Operator.



Some links on Ternary Operators:

http://stackoverflow.com/questions/694814/ternary-operator-bad-or-best-practice

http://programmers.stackexchange.com/questions/28314/ternary-operator-considered-harmful

http://thedailywtf.com/articles/One-Bad-Ternary-Operator-Deserves-Another

https://agiletribe.wordpress.com/2011/11/01/21-avoid-ternary-conditional-operator/

http://discuss.fogcreek.com/joelonsoftware/default.asp?cmd=show&ixpost=142517

http://en.wikipedia.org/wiki/Talk%3A%3F%3A
"I don't know how to do so, but this page should be flagged as being a very biased viewpoint. The text runs counter to my experience of 20+ years as a professional software programmer. The only people who prefer the ternary conditional operator to the more readable if-then-else format (when both are allowed by the language syntax) are those people who have never had to maintain other people's code bases for any significant period of time. This opinion is found in industry standard texts, such as "Code Complete" by Steve McConnell. I would love to see a valid citation supporting the viewpoint presented here, i.e. that the ternary operator is NOT considered to be antiquated, harder to debug, and harder to maintain."

Friday, November 21, 2014

Azure and FTP

"
To use an FTP tool, you need three things: the FTP URL, the user name, and the password.
The URL is shown on the web site's dashboard page in the Windows Azure Management Portal, and the user name and password for FTP can be found in the .publishsettings file that you downloaded earlier. The following steps show how to get these values.
  1. In the Windows Azure Management Portal, click Web Sites tab and then click the staging web site.
  2. On the Dashboard page, scroll down to find the FTP host name in the Quick Glance section.
    FTP host name
  3. Open the staging .publishsettings file in Notepad or another text editor.
  4. Find the publishProfile element for the FTP profile.
  5. Copy the userName and userPWD values.
    FTP credentials
  6. Open your FTP tool and log on to the FTP URL.
  7. Copy app_offline.htm from the solution folder to the /site/wwwroot folder in the staging site.
    Copy app_offline
  8. Browse to your staging site's URL. You see that the app_offline.htm page is now displayed instead of your home page."



UPDATE
Getting this, so doesn't seem to work:
Response: 150 File status okay; about to open data connection.
Error: Connection timed out
Error: Failed to retrieve directory listing