Saturday, 26 April 2014

Start PXE Over IPv4

Question:

My six months old HP Laptop which was working fine all along, once did not boot and I could see the text "Start PXE over IPv4" in the black MS DOS like screen and was unresponsive to keyboard and mouse. I waited for some time and then used the power button to hard shut down and then powered it again. This time it booted normally without any issues. Though the problem did occur thereafter, I am curious to know what PXE is all about. Can you explain what it is and the reason for it showing up?

By: Anonymous

Answer:

PXE is the short form for Preboot Execution Environment.It allows PCs or laptops to boot over a network as against booting from the local hard disk. Those who have worked with Novell Netware should be familiar with this network booting, where the Network Interface Cards carry a small add on chip containing the Network Boot Program, which will perform the boot over the network.

To address the large deployment challenges, Microsoft began developing the technology that would allow for network-based installation and PXE was the solution for this. To PXE boot a PC, the BIOS should be setup to boot from network. When set so, the BIOS will first get an IP address for the PC from the PXE Server and thereafter to get the boot image using TFTP on to the RAM and then boot out of that image.

Now in your case, as you have described the issue, it just happened, without you changing any BIOS setting. Normally the BIOS have multiple boot options configured with an order of priority. Your BIOS probably had the Network boot as one of the boot options and on that occasion, for some reason, your hard drive would have been unresponsive for a moment at the time of boot, as the next choice, the BIOS would have attempted to boot from network using PXE. As it might not find a PXE server over the IPv4 network it stayed there. 

You can check the BIOS by pressing F2 when your laptop boots and check if the network boot is configured as an option. You may disable this option, if you are not using the Network booting in your environment. On a different note, you may want to check why your local hard disk was not responsive for the boot on that occasion. That could be an odd occurrence and  the disk may be just fine too.

To know more about PXE booting, check the following resources:

Sunday, 16 March 2014

Code Quality - Refactoring

Question:

My project team has been asked to improve code quality by performing refactoring. I know that code refactoring is all about reviewing the code and ensuring that it follows the best coding practices. I however seek your guidance as to what are the aspects one should look into while performing code refactoring and also point me to some references, where I can learn more about the same.

By: Rajesh Dhawan


Answer:

Your question has the answer to some extent. Martin Fowler and Kent Beck originally defined refactoring as "a change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior… It is a disciplined way to clean up code that minimizes the chances of introducing bugs". Refactoring can be as minor as an inline change or it could be a massive code rewrite. Though large scale code refactoring can be an architectural redesign, as long as it does not change the business logic and when it is done in steps, it can be called as refactoring as well.


This is mostly done to improve the non-functional attributes of the program thus leading to improved code readability and maintainability. The design priorities or constraints for the enterprise applications are usually defined by the Enterprise Architecture teams, considering the vision, mission and goals of the enterprise and in turn the IT organization. Having said that while refactoring is all about making code changes to make it conform to the non functional attributes like maintainability, scalability, performance, etc, the specific design best practice or design pattern to consider would differ case to case.


Ideally, refactoring is done in iterations and technically there is no end to refactoring. However, one can say that refactoring ends when the code becomes 'simple', in which case, the definition of simple is subjective. As a programmer, you should be able to smell your code to figure out whether it needs refactoring. Here are some situations when your code smells, inviting you to refactor:

  • Duplicated Code - extract out the common bits into theirown method (extract method) if code is in same class if two classes duplicate code, consider extract class to create a new class to hold the shared functionality.
  • Long Methods - extract method!
  • Large Class - Class trying to do too much often shows up as too many instance variables.
  • Long Parameter List - replace parameter with method (receiver explicitly asks sender for data via sender getter method) Example: day month, year, hour minute second ==> date
  • Divergent Change - If you have a fixed class that does distinctly different things consider separating out the varying code into varying classes (extract class) that either subclassor are contained by the non-varying class.
  • Shotgun Surgery - The smell: a change in one class repeatedly requires little changes in a bunch of other classes. try to move method and move field to get all the bits into one class since they areobviously highly dependent.
  • Feature Envy - Method in one class uses lots of pieces from another class. move method to move it to the other class.
  • Data Clumps - Data that's always hanging with each other (e.g. name street zip). Extract out a class (extract class) for the data. Will help trim argument lists too since name street zip now passed as one address object.
  • Switch (case) statements - Use inheritance and polymorphism instead (exampleof this was in Fowler Chapter 1; this is one of the more difficult refactorings)
  • Lazy Class - Class doesn't seem to be doing anything. Get rid of it!
  • Speculative generality - Class designed to do something in the future but never ends up doing it. Thinking too far ahead or you though you needed this generality but you didn't. like above, collapse hierarchyor inline class
  • Message chains - Say you want to send a message toobject D in class A but you have to go through B to get C and C to get D. use hide delagate to hide C and D in B, and add a method to B that does what A wanted to do with D.
  • Inappropriate Intimacy - Directly getting in and munging with the internals of another class. To fix this, move methods, inline methods, to consolidate the intimate bits.
  • Incomplete Library Class - If method missing from library, and we can't change the library, so either: o make this method in yourobject (introduce foreign method) If there is a lot of stuff you want to change: o make yourown extension/subclass (introduce local extension)
  • Data Class - We have already talked about this extensively: in data-centric design, there are some data classes which are pretty much structs: no interesting methods. first don't letother directly get and set fields (make them private) and don't have setter for things outsiders shouldn't change look who uses the data and how they use it and move someof that code to the data class via a combinationofextract method and move method (see the Fowler chapter 1 example for several examplesof this)
  • Comments - Comments in the middleof methods are deodorant. You should really refactor so each comment block is its own method. Do extract method.

Check out the following to know more on the subject:

Friday, 28 February 2014

TIFF image support in HTML5

Question:

I am working on a requirement to display multi-page tiff image in a web application. We have been exploring the new canvas feature of html5 but find that handling multiple pages in the tiff image using canvas a bit of challenge. Please share some ideas in resolving this which would be a great help. You may direct me to javascript or such other resources that might help addressing this. Thanks in advance.

By: Nilima Jain

Answer: 

Though most browsers support the canvas feature of HTML5, the tiff format is not supported by all browsers, though IE supports it. So, first ensure you have an agreement on the supported browsers for which you are building this feature, or else you would need a plugin / control for handling tiff images. If you are taking the plugin or activex or applet route, then you have the liberty to make use of some of the client libraries and expose methods to interact with javascript calls from the browser and you are done.

Just in case you are fine with the browser support and are looking for using canvas for handling tiff, then try exploring the tiff.js library. Google also has a code library called tiffus. But I have not personally explored these libaries and you may spend some time trying out these whether these are of any help.

The other approach could be to try out the following approach:

Have a server side component with service APIs to be able to split the pages in the tiff image into multiple jpg images of the same resolution. This service API when queried without any specific page number would load the tiff image and have the pages parsed as individual images and would return the binary of the first page as jpg format. Similarly, the API, when queried with a specific page, it would ensure returning the specific page. The challenge with this approach would be that there would be more hits between the client and server. This can however be optimized by handling this process in-memory and thus minimizing the disk i/o on the server. This approach is likely to work with all browsers and the canvas feature can be leveraged as well.

However, if you have a specific browser to work with, for instance Internet Explorer, the best and easy approach would be to build an ActiveX control and wrapping the tiff image handling within it. In this case, the native windows imaging components might just suffice and no need for a third party library to handle the multi-page tiff image. This ActiveX component should expose necessary APIs, which can be invoked by javascript in response to various events at the client side.

There are quite a few third party commercial libraries to meet this need too.

Sunday, 26 January 2014

Continuous Integration in Agile Software Development

Question:

I am a fresher and have recently joined an IT firm as a .NET developer. After 15 days of orientation and training I am not part of a project team. I have been hearing a lot about Continuous Integration. Can you help me understand what it is and how does it help the project execution?

By: Rajesh Narayanan

Answer:

One of the important reason behind the software project failure was that the defects or issues discovered in the later phases proving to be too expensive to address and thus adding to the time and cost of the project. The industry has come up with different methodologies to address such issues and thus Agile Methodology has gained much adoption and recognition. As you may be aware, one of the key principles of Agile is to put in processes and techniques, so that the defects or issues are detected early on and thus giving opportunity to address sooner. Practices like SCRUM, Pair Programming, Test Driven Development are all expected to address this issue of catching the defects early on. On the same lines Continuous Integration and Deployment also contributes towards offering an opportunity to discover issues early on by offering the customer a working software product every now and then.

Traditionally, developers work on building components or modules independently and there will be a phase which will be fairly closer to UAT for integrating these modules together. No wonder, the development teams will discover many inconsistencies leading to the modules not working in tandem as intended. This calls for rework on one or more of the already built modules.

Continuous Integration addresses this problem by ensuring that every time the developer checks-in the code changes, the code modules are integrated with other related modules and deployed as well. This activity is best achieved by automating the build and deployment process. That means, the developer as he checks in code changes, will see the build and deployment errors and or warnings, which are expected to be resolved then and there, so that every code change that is checkedin does not break the working product. Thus the end customer will be able to see a working product always and able to validate the change as it is implemented.

The following are some of the key practices that makes the Continuous Integration workable and useful as well:


  • Maintain a Single Code Repository - Continuous Integration won't work if developers maintain isolated code repositories for different component or modules. There are plenty of open source and commercial source code control tools that offers robust conflict resolution techniques and facilitates usage of single code repository.
  • Build Automation - The Continuous build and deployment activity is best accomplished by automating the same. Most of the programming languages support this requirement and tools like CruiseControl are also very useful to accomplish this.
  • Test Automation - The automation process shall also execute the basic tests by itself. this where Test Drivent Development is in use. The developers, as they write code are also expected to create test scripts, so that these will also be executed during the automated build process.
  • Frequent Code Commits - The developers should commit the code more frequently and at the least every day. They should commit the code after every logical completion of a code change, so that the build does not break. This where, the Agile principles revolves around braking the coding tasks into smaller units, so that such tasks typically take 8 or 16 hours to complete.
  • Automated Deployment - Coupled with build automation, the code should also be deployed on to the test environment, so those involved in testing see the latest changes as soon as they are committed into the repository.


Hope the above explains the purpose and the principles of Continuous Integration. You can look up Martin Fowler's article on the subject to know more.

Thursday, 16 January 2014

Essential Skills For an UI Architect

Question:

I have been working on designing and building web applications both for mobile and desktop and am getting exposed to related tools and languages as well. I want to further improve my skills and want to shape myself as an UI Architect in the longer term. I seek your advice and guidance on pursuing my career in that direction.

By: Rajkumar Krishnan

Answer:

Given that you have experience and exposure on UI design, it is natural to aspire for becoming an UI Architect. As you would know, the word Architect has larger significance and calls for certain abilities which go beyond the core UI design. If you take a closer look, UI implementation is one aspect and UI design is another aspect of it. As an UI developer, you would be implementing the designs created by someone else, who is good at visualizing the user experience. It is essential that the UI designer also have sound knowledge on various current and emerging tools and technologies, so as to come up with a design that is implementable. The UI Architect role is much wider which should have the broader skills on every other related aspects of the solution being designed. Here are some of the essential skills an UI Architect should be capable of:

Core Skills: The core skills that an UI Architect should be capable of include but not limited to the following:

  • Ability to comprehend and discover the goals of the target users, motivations, and the work and interaction patterns and come up with a design that is intuitive, responsive and usable.
  • Exposure and ability to comprehend the Product design skills are very essential as UI does not stand alone and it has to be a part of the product that is being built. The UI that the architect comes up with should go well with the product design principles and concepts.
  • Good understanding on the information architecture is also key for a good UI design. Afterall the UI is all about presenting information to the users using different colors, layouts, graphics etc. Without a good understanding of the information and the inter relationships of the underlying data, the UI architect is most likely to end up with a poor design.
  • Great deal of understanding on the behavioral aspects of the users would be key to come up with a usable UI.
  • Testing skills are equally essential without which the design that the UI Architect comes up may not be testable at all.
  • Ability to unlearn is another key skill that every architect should posses. If you are a developer and if you know certain specific tools or technology you will tend to come up with a design that suits the tools or technology that you know but there are quite many other tools and technology out there which can assist to implement even better designs. While it is important that the design is implementable, the Architect should also understand that there is nothing that is impossible and should have wide exposure on various other current and emerging technology out there.
  • Should have sound knowledge on the fundamentals of the multi-media, for instance, in-depth knowledge on the various image formats and attributes, the technical attributes of the screens of differing sizes as used in desktop PC, smartphones, etc.

Other Skills: The following are some of the other related skills that an UI Architect should have:

  • Should be open minded without bias and should be able to sketch the visual UIs on paper or on appropriate drawing tools.
  • Should have reasonable business skills which will help in enhancing the ability to understand the interactions between the product and the human users, the motivation and goals of the end users, etc.
  • Should have very good communication and language skills. Needless to say that the UI Architect should have the documentation and presentation skills as well.
  • Other soft skills that are relatively important for any role are active listening, interviewing, observation, collaboration and inter-personal team skills, etc.
  • Know the art of trade-off. i.e. in any design there will be conflicting attributes and the architect should be good at trading off one for the other. For example, if response time is a key attribute for you, you cannot afford to use fat image in your design. You should be able to balance and trade off certain attributes for the other.

You may work towards sharpening your skills in the above areas you can eventually look at becoming an UI / UX Architect in the longer term. Good luck with your career aspiration.

Wednesday, 25 December 2013

TWAIN vs WIA

Question:

I have taken up an academic project to work with the imaging devices, like video and still image capture. I have read about TWAIN and WIA as the popular toolkits or APIs available for the purpose. I need help in deciding as to which API is good to go with and guidance on any other tools or SDKs would also be of help.

By: Matt Charles

Answer:

You are right that TWAIN and WIA are the widely used APIs for applications around image acquisition. The choice of the toolkit can be made by looking at the following criteria:


  • OS Support: Microsoft's Windows Image Acquisition apparently works only on Windows platform. But TWAIN works on Windows, Linux and Mac. If your project requires cross platform solutions, then look at TWAIN or else WIA is preferred for its other advantages. While TWAIN is an offering of TWAIN Working Group having leading device vendors as its members, WIA is Microsoft's offering which builds on top of low-level hardware abstraction STI and is available with Windows Me or later.
  • Programming Support: Working with TWAIN API require C/C++ skills. There are commercial high level libraries which expose various programming language specific APIs for ease of use. WIA, though primarily designed for C/C++ development, it offers ease of use with .NET programming languages as well.
  • Device Support: Most of the windows compatible imaging devices including digital cameras, webcams, video cameras and scanners are WIA compatible. But not all devices come with TWAIN support. The list of devices supported by the TWAIN specification 2.3.0 can be found here


TWAIN though originally developed in 1992, it is a sophisticated API and its portability across various platforms. TWAIN also offers a 'native' (Device Independent Bitmap) transfer mode in addition to the modes 'memory' and 'file' offered by WIA. WIA provides a TWAIN compatibility layer that allows TWAIN-aware applications to communicate with WIA devices, though such applications will not have full access to WIA functionality.

Here are some cool references or code samples for image acquisition using WIA

ADF Scanner Library
OpenNETCF WIA Library

Some of the commercial APIs that make building TWAIN aware applications a lot easier are:

EZTwain Pro 4.0
csXImage - ActiveX Image edit and Twain control

You may also want to explore JS-Feat a javascript library.

Assuming that your project is of academic nature and that you would be looking at a windows specific solution, I would recommend you to explore WIA.

Sunday, 24 November 2013

Chrome on Windows 8 Freezes often

Question:

I have been experiencing issues while using Chrome on Windows 8. Randomly the system PC become unresponsive to keyboard and mouse. While some times the freeze is for a few seconds, most of the times it never comes back. The PC then had to be hard rebooted. Though I have been experiencing more with Chrome on rare circumstances, the system did froze even when I was not using Chrome at all, For your information, I have applied all windows updates and the device drivers seem to be upto date. Any help in resolving this is highly appreciated.

By: Mohan Ramalingam


Answer:

There is no straight fix for this problem, as the cause for this issue could be many fold. For example, I have come across issues around solid state disks with inappropriate hardware and driver configurations. Generally, try these fixes and one of that could work for you.

  • Run the following command bcdedit /set disabledynamictick yes using the command prompt as an administrator and then reboot the system. Dynamic ticks, which exists in Linux for over a decade, is implemented in Windows 8 for the first time. This does not significantly benefit desktops, but mobile devices such as laptops, smartphones and tablets, are expected to be benefited in the form of extended battery life. Unfortunately, Microsoft’s implementation of dynamic ticks in the Windows 8 kernel does not go well, may be due to its dependency on some hardware devices and/or related drivers and thus causing the issue that you have described above. Disabling this on a desktop is unlikely to have any significant adverse impact.
  • It is widely reported that using a solid state disk with older SATA controllers, which are not designed to manage the higher speeds of SSDs could also cause similar issues. It is recommended to use SATA II controller based mother boards. Just in case if you are using an SSD, you may want to check the underlying hardware specifications and fix them if needed.
  • Other possible solutions include:
    • If the issue is specific to chrome, try disabling the chrome extensions on a trial and error basis and some users how found success in resolving the issue by disabling some of the fixes.
    • Ensure that all your hardware devices have latest drivers supported by Windows 8.
    • Run System File Checker tool to see if there are corrupt system files. For this, you may run the command sfc /scannow in a command prompt with administrator privileges. This will report if there are issues with system files and if so, you may want to reinstall or reset the Windows 8 operating system.
    • Defrag your hard drives
    • Clear history and temporary files

You may write a response to this post in the form of comments, if any of the above has helped resolve your issue.

Update:

If your experience of freeze is not specific to Chrome or any one application, then you have reason to suspect the hardware. Overheating CPU has been found to be one of the most common cause of such freezes. Ensure that the fan mounted on the Processor and other fans attached to the chassis are working fine. Use the hardware monitoring tools supplied by the manufacturer to keep a watch on the CPU temperature.

The next possible cause would be incompatible drivers. Ensure that you have all the hardware drivers updated. Usually, when you have upgraded your Windows 7 to Windows 8, it might be possible that the old drivers continue to be in use and Windows OS might not find updates. But driver updates could in fact be available from the device manufacturers. Better search for the appropriate updated drivers and apply them.