Posts

OnFragmentInteractionListener Implemented On Parent Fragment

If you're a Android Developer  OnFragmentInteractionListener Interface is not a new thing for you. It is the callback interface that comes with the auto-generated code, when you add a new fragment to your project in Android Studio. If you have some exposure, you already know that it is used to pass messages to Activity from within the Fragment Code. Even if you don't have any experience in android it's not something hard to understand. It is a pattern we always use in OOP languages for callbacks. You can know about it thoroughly, by reading my post,  Callbacks With Interfaces Or Delegates . Read the Java part there. Anyway in simple word, it's one class calling an interface method, and the other class is forced to implement that interface at creation. In most of the scenarios, this can be achieved by forcing to pass an interface implemented class through the constructor at creation. But as android works on a life cycle approach, the interface implemented class o

Callbacks With Interfaces Or Delegates

I'll start like this by directly jumping into a scenario. You have this one class, which has many methods called by different other classes. For the moment let's not think about those many methods and who calls those. Focusing on the the matter in hand the requirement is such, that you have to call a method in some other class, which will consume some time for execution. So that method runs that execution in a background thread inside, and only he knows when it finishes. In this scenario you have to give them something to call, may be some reference or some callback method, after the execution of the background thread is done. What I'm going to discuss now is the ways to do it. Delegates First I'll take you on the C#.NET road. In C# there is a very simple and straight forward way to do this, thanks to " Delegates ", which are reference points to the methods. In simple words, in a delegate you can put a method in there,

Multiple Inheritance with Interfaces

First things first. What is multiple inheritance means ? When one class can inherit characteristics and features from multiple classes, it's called as multiple inheritance. As an example, class FuelVehicle{ public void fillFuel(){ } } class ElectricVehicle{ public void charge(){ } } class HybridCar extends ElectricVehicle,FuelVehicle{ } HybridCar class inherits from both FuelVehicle and ElectricVehicle classes. Then HybridCar class get the ability of using the features of both the mother classes. In simple words, an object of the HybridCar class can call both the methods, fillFuel() and charge(). Up to now, all is well. But, there can be a problem in a scenario like the following. class Vehicle{ public void start(){ } } class FuelVehicle extends Vehicle{ public void start(){ //Overridden } public void fillFuel(){ } } class ElectricVehicle extends Vehicle{ public void start(){ //

WPF Dispatcher - Accessing UI Thread From Another Thread

If you're a C#.NET developer creating a WPF application and it's obvious that you could come across a scenarios to use multi threading. Have you ever tried to access an element in the UI from another thread and come across an exception with the following message ? "The calling thread cannot access this object because a different thread owns it." What's the reason for such message ? It's something like this. In certain programming languages the application starts with something called the main thread or the UI thread. And usually, the elements of the UI, are created with that main thread. When another thread tries to access it, that message is given. Put into simple words, "When you're doing something to one of the UI elements, you have to do it through the UI thread." The next question is,  how to do such thing ? When you're working with WPF, every thread has an associated Dispatcher which provides

Downgrade NuGet Packages - Visual Studio

Image
I came across this problem when I was working with the SignalR WebSocket . The project was already included with the references related to SignalR 2 Server application and I wanted to add  Newtonsoft.Json  library into my project for some json serialization and de-serialization. Added it without a problem, except there was an exception from SignalR. It needed Newtonsoft version 6.0 and adding Newtonsoft again has updated that reference to 9.0 which was the latest update for Newtonsoft. So following is the solution I used for downgrade Newtonsoft.Json back to version 6.0. 1. First you should get the Package Manager Console Window. It is reachable via  "TOOLS -> Library Package Manager -> Package Manager Console" . 2. Then you have to uninstall the current version of the library you want to downgrade, by executing the following command in the Package Manager Console. It's very important you use the -Force  flag, if there are dependencies to the package you&#

Installing Flask-SocketIO For Python 2.7

It may seem as a very simple thing if you search the internet for it, but it's not. Here I like to discuss about a problem that can occur with some python plugins. As mentioned in the most of the places to install this plugin, a developer can use the simple command, "pip install flask-socketio" after installing pip into your computer. But it won't be a good day scenario every time. While installing this plugin there is a problem that can occur. When installing this "flask-socketio", there is another dependent plugin that is installed, which is ' gevent '. And both these plugins use Visual Studio 2008, VC (Visual C) compiler to compile those plugins at installation. So if that version doesn't exist in the computer there will be a error as " Unable to find vcvarsall.bat " while installing that plugin. One solution for this problem is available if there is another higher version of Visual Studio is installed in your computer. In ther

Do's And Don'ts Related To Group Projects

Image
In my 3rd academic year, I had to face a subject which was an one year software development project. The module was called as  Software Engineering Project and while doing that project I was able to experience new Do's and Don'ts regarding group projects. 1. Planing before work Planning is an important thing in any group project. It becomes crucial in a software development project when considering about the integration of the project. Not only integration, but starting from the work allocation, there's lot of planning that has to be done in a project. So it's always a good habit to spend sometime for planning before you start the work. 2. Know your members When it comes to a group project, there has to be team work. That means each member has to work collaborating with the other members. It's rarely two people in the world have same attitudes regarding a particular matter. They all have their own opinions, mostly based on the previous experiences in