Skip to main content

Posts

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...

A post dedicated to Autodesk Maya and the Maya API

I wanted to write this post for a long time now. In my free time I also do 3D stuff like models and various other things. While doing these I came across Autodesk Maya and from a developer's perspective I like it a lot. It's one remarkable piece of software. Over the years it just kept growing and getting better. Today it has a huge variety of features and amazing support for developing various new components for it. I will start with the basics. Surprisingly for a program it has it's own dedicated scripting and programming language called Maya Embedded Language or MEL. In reality the entire application is just one interpreter that reads these MEL scripts to generate the user interface. As you have guessed by now, the entire user interface is written in MEL. It looks a lot like php and it has some special functions called commands which interact with Maya. With these commands we can add new menus or even edit 3D objects inside it. The partial script bellow is writte...

Part 2 of writting an expermental code analyzer and sort of interpreter for C#

This is a continuation of my blog series about writing a hybrid C# code analyzer and interpreter. Compared to part one, I renamed the variable references from "TrackedVariableReference" to "EvaluatedObjectReference" and a variable is now known as an "EvalutedObject" or any subtypes derived from it. This part will focus on the simulation of the code execution. The core part is the object that stores the current execution state which is of type "CodeEvaluatorExecutionState". The most important things stored in this state object are the objects of the type "CodeEvaluatorExecutionFrame". These objects represent a method call and store all the local parameters corresponding to a method call. These parameters include the local "this" reference, the local objects created inside the method, the passed parameters from caller of the method and a special slot for a reference which contains the results of an expression. This last slot ...

An inside look at a serious open source project called Blender 3D

I am writing this because some time ago I took a look inside the source code of the most popular 3D open source computer graphics software called "Blender 3D". I didn't have a blog at that time and I feel like I learned a lot just by studying the source code of this program. To start things, Blender is actually written in C mostly with some parts in C++ and some parts in Python. To make matters a bit more confusing, the parts written in C actually represent the MVC design pattern. Yes, I know. C isn't really an object oriented programming language and yet here we have an application written in C that implements the MVC design pattern. So how does it implement the MVC design pattern? The application is separated into 3 main areas. The first area contains the operator and operator types. An operator type pretty much describes any action a user can execute inside the program that alters the data in the program. The operator represents an actual instance of an opera...

Some small observations about working in a team

As we approach the first official delivery of the automated laboratory system on which I have been working on for the past couple of years with my colleagues I realized some important conclusions about working in a team. I realized now that all of us from my team have kind of grown together over the past couple of years. All those challenging situations, funny moments and hard work have brought us together without us even knowing. When I first started in this team, we were all quite different and initially kind of cold to each other. Especially my boss but I think that is expected since he is in a delicate position and so I understand him. But as we worked more and more together, we kind of slowly started opening up. I realized then that it's not enough just to be colleagues in order for a team to work. You actually need to see everyone as a bit of a friend. Why you ask me? Because only then you will feel free to collaborate with other people to work together on something. I no...

Why big tasks are hard to estimate properly and what to do about this.

I will begin this by stating clearly: you should never get to the point where you need estimate how long it will take a big task to be completed. You should never have big tasks in the first place. There are a lot of reasons why having big tasks is a seriously bad idea. Firstly, big tasks have big requirements and by the time the developer is halfway there he will most likely have forgotten parts of the requirements. A developer working on a big task needs to keep the requirement fresh inside his mind each day. Otherwise if he forgets some things he won't implement them at all. This is an issue even where I work. So extra time is wasted just refreshing those requirements. Secondly, big tasks tend to affect a lot of systems inside an application. Most developers don't know all the systems in the application so he might spend a lot of time figuring out how those systems work and how does his task affect those systems. A series of smaller tasks can be worked on...