What google did right:
- Technical talks , meetings to share knowledge across teams
- Tiger teams
- Code modularization and Monorepo
- Not jumping onto new languages without whetting the maturity (swift)
- Enforcing no usage of Xibs and Storyboards because it doesn’t scale to the disciplines on the team
- Listening to users – productforums
- Using different languages (Java in objC, C++ through Xcode) – for eg. libraries written in different languages
- Up to date features with iOS features
This is the list of things I learn when learning a new or re-learning an old programming language.
Section 1 – Training wheels
- Variables and types
- Basic Program structure
Now you should be able to write small programs / scripts in the programming language
Section 2 – Interview readiness
- Data Structures – Set, array, list, Dict
- File- IO
At this point you will have enough skills to solve interview programming questions, hackerrank problems etc.
Section 3- Advanced levels
- Reading and exporting Libraries
- HTTP Programming – GET, PUT, POST, DELETE
- Handle errors
- Socket Programming
- Language specific features
- OO / Functional paradigms
At this point you will be ready to contribute to opensource projects and working with other programmers on projects.
The normal code flow for editing/creating an entity in MVC looks something like this
Sometimes, when you want to display a notification back to the user, it is conventional to do so by using the message in a query string
This sends out a URL like http://localhost:23000/Cart/Index?message=saved%20successfully
But this has a couple of disadvantages :
- The url is ugly
- If you hit F5 again, the message appears again, as if it were saved again.
One way to get around the ugly url problem is to use the ViewBag to set a Message and display it from the View, but that doesn’t solve the second problem of multiple error messages being shown.
There is another dictionary typically for this same use case. It is called the TempData dictionary.
The cool thing with the TempData dictionary is that it is implemented as a limited access dictionary. This means that you can access a key value pair one time and then that key loses its associated value. This solves both our problems pretty well.
I just found out today a peculiar behaviour of model binding in MVC-3. At first I thought iit was a defect but I later learnt that it was by design. So in a line, I learnt that primitive type properties in your model are treated as if the [Required] attribute were marked on them.
Now when you use Razor top generate a textbox for each of the above fields,
You can notice that the HTML code that is spit applies the required validations for all the primitive type properties on the Student class, but not for the Name property.
Notice how the Score and the Grade properties are being rendered with htmkl attributes for required Validation but not the name? The reason for this seemingly weird behaviour is that since these properties have primitive types, they have no notion of nullabality within them and when the user posts back the form , without entering a value into these fields, the Model binder will try updating these properties with a null value. Instead of failing that way, the framework assumes that you have those types as non nullable for a reason. It assumes that you really do know what you are doing.
How to get around this ?
The simple way, whatever properties you are sure that need not be required fields during user Input, mark them as nullable fields.
R is a statistical tool used by economists and non programmers. It is a language that was specifically intended for data crunching problems. This post is about how you can set up R as a web server and send HTTP requests to R and getting responses.
The module in R that makes it possible to use it as a HTTP server is called Rook. Here’s a simple script that sets up the server to return 42 as the response always, no matter what.
Load the script, select the entire script and hit CTRL + R . You should be able to see something like this on the R Console.
Now that the server has started, you can hit the server from the browser like so :
The ViewBag property in ASP.NET MVC makes a lot of things much more easier. One of the obvious advantages is that since it is a dynamic and it operates just as a key value store, you can pretty much put anything into it to be rendered in the View from the controller. You are mot forced to write models(or view Models) just to render some obsucre property that does not really deserve the status of existing in a higher level data structure. While the VIewBag makes a lot of things very easy for us during development, it is worth putting some effort to understand how the framework handles/implements the ViewBag. The ControllerBase class defines the Viewbag as dynamic item.
In normal usage, you could set any property on the ViewBag and return a ViewResult from an action method. If you are referring to the same property of the ViewBag on the .cshtml file, you get the value that you put in the controller rendered on the View. So the View method on the Controller that must be responsible for passing around the ViewData/ViewBag. If you look at the implementation of the ViewBag, you can see that it is heavily dependent on the ViewData object. Whenever you set a value on the Viewbag, a key-value pair is inserted in the ViewData dictionary and so you can get/set properties interchangeably between the ViewData and ViewBag.
The ViewResultBase class also has a ViewBag property declared in the same way as declared in the Controller base. Since this Viewbag property also depends on the ViewData object for getting/ setting property values, and since the View() method sets the ViewResultBase.ViewBag to the ControllerBase.ViewBag, whatever property you set on the ViewBag from the Controller can be accessed from the View.
Sometimes, we tend to use language features without knowing whether using that feature really offers a benefit. I recently saw one such example. The problem to be solved was to clone a huge array from one variable to another. Someone decided to get creative and used Parallel.For() to achieve the task. I decided to inspect, along with a couple of friends what this method implied and whether it offered any performance improvements.
We tried out three approaches to solve the problem :
- Naïve array indexed copying
- Using Object.clone()
It turns out that Parallel.For() is actually the slowest method. Naïve array indexed copying comes in second, but it is more than 4 times faster. Object.Clone() comes in first.