Skip to main content

Posts

Speeding up request processing on a server

So lately I had to speed up the server with my colleagues at work so it could process requests faster. In our case we have a lot logic that needs to be executed which takes a bit of processing power, it's not a normal web server that just renders a simple page. There are tens of thousands of lines of code that need to be executed and not a couple of hundreds or a few thousands in the case of a normal web server. And to successfully process a request a lot of times the server needs to put the request on-hold until it receives all information about that request freeing that thread to process another request. This is the first place where performance issues can arise because of context switching. Once a request is put on-hold and after that reprocessed, all the context must be restored. This can involve loading heavy stuff from the database. Ideally you should make sure that you load the context from the database once a request is actually ready to be processed and once all the requ...

My 2 cents on 6 aspects of a developer's job

Over the past years or so I has the chance to speak with some developers from many different areas and countries. After all those talks and some introspection I came with the conclusion that programming usually involves 6 aspects to varying degrees. These aspects are in no particular order: Technologies: This relates to what technologies you use at your job. Some jobs require that you know in depth because most of them have their quirks and pitfalls. Or maybe they are hard to to learn or use in general. Usually I would  include here stuff like programming languages, database types, various ORMs, IDEs, frameworks and prebuilt libraries to make your life easier. This doesn't really involve a lot of creativity and thinking but rather knowledge. You don't really need an innate ability and talent for these things. Just curiosity. Architecture/Software design: This is related more to object oriented programming and how you structure your code into various modules and components....

Simple tutorial about configuring and using a virtual machine in Microsoft Azure

Lately while doing some kind of homework for my master's degree I wanted to try something which I haven't done in a long time. So I bough a virtual machine on Microsoft Azure using their pay-as-you-go billing scheme. I forgot how easy it was and useful is to do this, so I decided to write this simple tutorial. If you just want an extra machine to use from time to time with a bit of power this is the way to go. People that do 3D graphics and stuff can benefit a LOT from this. Imagine having a 16 core powerhouse at your disposal. Actually the people at Azure made some dedicated cloud services just for rendering. Currently only Maya and 3D Max are supported. You can find more information about the service here: https://rendering.azure.com/ Their pay-as-you-go billing scheme is brilliant. You just pay the time the virtual machine is online. When you don't need it anymore you just can stop it and you won't be billed anymore.If you don't use it that often it is actual...

Some advanced things about methods, fields, delegates and members in C#

I had the chance to dig deeper into how C# handles members in general and came up with some really interesting conclusions. This post is mostly about how C# and the CLR resolves fields and methods calls with the corresponding implications. This is especially good to shut up someone if you do an interview with a know-it-all interviewer.. Actually is it pretty interesting because in C# you can actually have multiple fields with the same name in an object. But there is a small gotcha: you can't declare the duplicate fields in the same class definition. So how can you do this? Well you use inheritance. You can have a simple class that inherits from another base class declaring another field with the exact same name as field from the base class. They will look like this: In this case, what field will be accessed from these duplicate fields? It's actually pretty simple. It depends on how you reference the object. Each object has a type which can be a class, structure or some...

Making a simple modular single paged website using ASP .Net MVC and knockout.js

This post will be about how to make a simple website that supports multiple modules which are displayed in a single page. By default unlike a lot of other javascript frameworks, knockout.js doesn't really support modules. But fortunately we can implement this functionality using knockout.js itself. We are also going to use bootstrap because it already has builtin support for tabs and other useful features. The structure of the website will be based on tabs. On the left of the tab header bar we will have a menu from which we can select a module to open just by clicking on it. Once we open a module, a tab header will appear up in the tab header bar with the name of the module. And down in the tab content pane, the content of the current tab will appear. Bellow we can see a sketch of the website: We will have a javascript object type which will hold the name, id and functions to load and unload a module from the module tab content area. It looks like this: ...

A post about generating stream reading and writing libraries from specifications

This post is about generating a file reading/writting library from some sort of specifications, in this case in the form of an xml file that details the internal binary structure of the file. Using this approach, we can define the format in an xml file and create some code generating tools to write code for libraries which read and write in that format for a given language such as C++ or python. These tools will also create some models in the respective programming language that are read and populated by the generated library. This has the advantage in case the format changes we just run the tool again with the updated format from the xml file. The code for reading the format will be updated and all that we need to do is to recompile it. It also allows people who are not familiar with programming to edit the format without writing code. I am going to use an open source project called niflib which reads and write 3d models in files for games like Elder Scrolls Skyrim. You can find...

A bit about .tt templates used in Entity Framework and not only

Most developers that have used Entity Framework will surely have noticed some special files in the project that end in ".tt". These files serve as blueprints for the code that is generated from the Entity Framework mappings which are stored in an xml file ending in ".edmx". A ".tt" template is similar to the ".cshtml" files used in Asp .Net MVC but instead of rendering html content it renders C# code. By editing these files we can customize how the generated code will look and behave. For example the partial ".tt" template bellow for each column in a table in the database it generates a property that implements the INotifyPropertyChanged interface to notify subscribers that the object has changed: This is applied for each column in every table. Using this code we can bind our objects directly to a Windows Presentation Foundation interface after fetching them from the database. We can also generated backing fields for that prop...