The Model View Presenter pattern in C# – a minimalist implementation

The Model View Presenter (MVP) is a design pattern that is particularly useful for implementing user interfaces in such a way as to decouple the software into separate concerns, such as those intended for data processing and storage (model), business logic, the routing of user commands, etc, thereby making more of your code available for unit testing.

The MVP design pattern separates the following concerns:

The Model. Stores the data to be displayed or acted upon in the user interface.
The View. A passive user interface that displays the model data and routes user-initiated events such as mouse click commands to the presenter to act upon that data.
The Presenter. Acts upon the model and the view. It retrieves data from the model, and displays it in the view.

MVP_3
Continue reading ‘The Model View Presenter pattern in C# – a minimalist implementation’ »

Changing the font size of the ‘Syntaxhighlighter’ plugin

Syntaxhighlighter is a GREAT plugin for posting code samples on your website.

I know because I use it on here.

My only minor gripe was in the size of the actual font itself – it was too large for my own preference.

Modifying the size is simple, and I’m going to post it here for future reference.
Continue reading ‘Changing the font size of the ‘Syntaxhighlighter’ plugin’ »

Windows programming using MinGW

A short example of how to started with Windows programming in non-Visual Studio environments.

In this example, we use the MinGW (Minimalist GNU for Windows) compiler within the Code::Blocks integrated development environment.

MinGW can be obtained via the following link:

http://www.mingw.org/

First select File > New > Project… and opt to create a new empty project:
Continue reading ‘Windows programming using MinGW’ »

Creating and avoiding deadlock conditions in C++

A short and to-the-point post illustrating how a deadlock situation can be created in C++, together with a possible strategy for avoiding such a condition.

I’m am using the boost libraries to implement threads and mutexes, but it should be possible to the standard library implementations std::thread, std::mutex etc as well.
Continue reading ‘Creating and avoiding deadlock conditions in C++’ »

Using sc.exe to communicate with Windows Services in Visual C++

SC.exe is commonly used to retrieve and set control information about installed Windows services. Common tasks are to configure, start and stop a service, as well as retrieve the status of a specific service. These tasks can be achieved by executing sc.exe inside a command prompt as a batch (.bat) files that can call combinations of sc.exe commands to automate startup or shutdown of services.
Continue reading ‘Using sc.exe to communicate with Windows Services in Visual C++’ »

Getting started with client-server applications in C++

A demonstration of simple Internet client-server applications in C++ (Linux-based).

The client application tries to connect to the remote server application using the IP address of the remote server (‘localhost’ or 127.0.0.1) and the server port number which defaulted to 1234.

The server application listens to port number 1234 for a connection request. When the server application receives the connection request it sends the text message “Hello!\r\n” to the client.
Continue reading ‘Getting started with client-server applications in C++’ »

Configuring Code::Blocks to use OpenCV in Linux Environments

A quick guide to setting up and installing OpenCV for using in the Code::Blocks integrated development environment in Linux. The version of Linux I am currently using is Ubuntu 14.04. At the time of writing the version of OpenCV for Linux used is 2.4.9. (I had originally tried version 2.4.10 but had problems compiling it with the version of gcc I had (4.8.2), so I reverted to 2.4.9 instead.) Continue reading ‘Configuring Code::Blocks to use OpenCV in Linux Environments’ »

Configuring Code::Blocks to use the Boost Libraries in Windows and Linux

Some examples of how to configure Code::Blocks to use the Boost C++ libraries:

1. Header-only (Windows)
2. Compiled libraries (Windows)
3. Compiled libraries (Ubuntu Linux)

1. Header-only (Windows)

To configure Code::Blocks to use a header-only Boost library: Boost.DateTime. Select File > New > Project > Empty Project:

CodeBlocks1
Continue reading ‘Configuring Code::Blocks to use the Boost Libraries in Windows and Linux’ »

Obtaining Media File Information in Visual C++ Using FFPROBE

A short demonstration on how to utilize the ffprobe command to extract information about media files such as wav / MP4 files.

The ffprobe executable comes with the complete ffmpeg package and can be obtained from here:

https://www.ffmpeg.org/

Once downloaded and installed, the ffprobe executable resides alongside the ffmpeg and ffplay executables as shown:

ffmpeg1
Continue reading ‘Obtaining Media File Information in Visual C++ Using FFPROBE’ »