Monday, February 3, 2014

AngularJS vs jQuery: Difference between AngularJS and jQuery: Never mix up AngularJS and jQuery code

AngularJS vs jQuery: Difference between AngularJS and jQuery: Never mix up AngularJS and jQuery code

AngularJS and jQuery are the Javascript frameworks and are different with each other, so never mix up the AngularJS and jQuery code in your project. Use only one Javascript framework at a time. If you are starting a new project, must consider AngularJS over jQuery. If you are a experienced jQuery developer, then you have to invest some time to work in AngularJS way. There are a lot of difference between AngularJS and jQuery.

1. Web designing approach in jQuery and AngularJS

In jQuery, you design a page, and then you make it dynamic. This is because jQuery was designed for augmentation and has grown incredibly from that simple premise.

But in AngularJS, you must start from the ground up with your architecture in mind. Instead of starting by thinking "I have this piece of the DOM and I want to make it do X", you have to start with what you want to accomplish, then go about designing your application, and then finally go about designing your view.

2. Don't augment jQuery with AngularJS

Similarly, don't start with the idea that jQuery does X, Y, and Z, so I'll just add AngularJS on top of that for models and controllers. This is really tempting when you're just starting out, which is why I always recommend that new AngularJS developers don't use jQuery at all, at least until they get used to doing things the "Angular Way".

I've seen many developers here and on the mailing list create these elaborate solutions with jQuery plugins of 150 or 200 lines of code that they then glue into AngularJS with a collection of callbacks and $applys that are confusing and convoluted; but they eventually get it working! The problem is that in most cases that jQuery plugin could be rewritten in AngularJS in a fraction of the code, where suddenly everything becomes comprehensible and straightforward.

The bottom line is this: when solutioning, first "think in AngularJS"; if you can't think of a solution, ask the community; if after all of that there is no easy solution, then feel free to reach for the jQuery. But don't let jQuery become a crutch or you'll never master AngularJS.

3. Always think in terms of architecture

First know that single-page applications are applications. They're not webpages. So we need to think like a server-side developer in addition to thinking like a client-side developer. We have to think about how to divide our application into individual, extensible, testable components.

So then how do you do that? How do you "think in AngularJS"? Here are some general principles, contrasted with jQuery.

The view is the "official record"

In jQuery, we programmatically change the view. We could have a dropdown menu defined as a ul like so:

<ul class="main-menu">
    <li class="active">
        <a href="#/home">Home</a>
    </li>
    <li>
        <a href="#/menu1">Menu 1</a>
        <ul>
            <li><a href="#/sm1">Submenu 1</a></li>
            <li><a href="#/sm2">Submenu 2</a></li>
            <li><a href="#/sm3">Submenu 3</a></li>
        </ul>
    </li>
    <li>
        <a href="#/home">Menu 2</a>
    </li>
</ul>

In jQuery, in our application logic, we would activate it with something like:

$('.main-menu').dropdownMenu();

When we just look at the view, it's not immediately obvious that there is any functionality here. For small applications, that's fine. But for non-trivial applications, things quickly get confusing and hard to maintain.

In AngularJS, though, the view is the official record of view-based functionality. Our ul declaration would look like this instead:

<ul class="main-menu" dropdown-menu>
    ...
</ul>

These two do the same thing, but in the AngularJS version anyone looking at the template knows what's supposed to happen. Whenever a new member of the development team comes on board, he can look at this and then know that there is a directive called dropdownMenu operating on it; he doesn't need to intuit the right answer or sift through any code. The view told us what was supposed to happen. Much cleaner.

Developers new to AngularJS often ask a question like: how do I find all links of a specific kind and add a directive onto them. The developer is always flabbergasted when we reply: you don't. But the reason you don't do that is that this is like half-jQuery, half-AngularJS, and no good. The problem here is that the developer is trying to "do jQuery" in the context of AngularJS. That's never going to work well. The view is the official record. Outside of a directive (more on this below), you never, ever, never change the DOM. And directives are applied in the view, so intent is clear.

Remember: don't design, and then mark up. You must architect, and then design.

Data binding

This is by far one of the most awesome features of AngularJS and cuts out a lot of the need to do the kinds of DOM manipulations I mentioned in the previous section. AngularJS will automatically update your view so you don't have to! In jQuery, we respond to events and then update content. Something like:

$.ajax({
  url: '/myEndpoint.json',
  success: function ( data, status ) {
    $('ul#log').append('<li>Data Received!</li>');
  }
});

For a view that looks like this:

<ul class="messages" id="log">
</ul>

Apart from mixing concerns, we also have the same problems of signifying intent that I mentioned before. But more importantly, we had to manually reference and update a DOM node. And if we want to delete a log entry, we have to code against the DOM for that too. How do we test the logic apart from the DOM? And what if we want to change the presentation?

This a little messy and a trifle frail. But in AngularJS, we can do this:

$http( '/myEndpoint.json' ).then( function ( response ) {
    $scope.log.push( { msg: 'Data Received!' } );
});

And our view can look like this:

<ul class="messages">
    <li ng-repeat="entry in log">{{ entry.msg }}</li>
</ul>

But for that matter, our view could look like this:

<div class="messages">
    <div class="alert" ng-repeat="entry in log">
        {{ entry.msg }}
    </div>
</div>

And now instead of using an unordered list, we're using Bootstrap alert boxes. And we never had to change the controller code! But more importantly, no matter where or how the log gets updated, the view will change too. Automatically. Neat!

Though I didn't show it here, the data binding is two-way. So those log messages could also be editable in the view just by doing this: 
<input ng-model="entry.msg" />. 
And there was much rejoicing.

Distinct model layer

In jQuery, the DOM is kind of like the model. But in AngularJS, we have a separate model layer that we can manage in any way we want, completely independently from the view. This helps for the above data binding, maintains separation of concerns, and introduces far greater testability. Other answers mentioned this point, so I'll just leave it at that.

Separation of concerns

And all of the above tie into this over-arching theme: keep your concerns separate. Your view acts as the official record of what is supposed to happen (for the most part); your model represents your data; you have a service layer to perform reusable tasks; you do DOM manipulation and augment your view with directives; and you glue it all together with controllers. This was also mentioned in other answers, and the only thing I would add pertains to testability, which I discuss in another section below.

Dependency injection

To help us out with separation of concerns is dependency injection (DI). If you come from a server-side language (from Java to PHP) you're probably familiar with this concept already, but if you're a client-side guy coming from jQuery, this concept can seem anything from silly to superfluous to hipster. But it's not. 

From a broad perspective, DI means that you can declare components very freely and then from any other component, just ask for an instance of it and it will be granted. You don't have to know about loading order, or file locations, or anything like that. The power may not immediately be visible, but I'll provide just one (common) example: testing.

Let's say in our application, we require a service that implements server-side storage through a REST API and, depending on application state, local storage as well. When running tests on our controllers, we don't want to have to communicate with the server - we're testing the controller, after all. We can just add a mock service of the same name as our original component, and the injector will ensure that our controller gets the fake one automatically - our controller doesn't and needn't know the difference.

4. Test-driven development 

This is really part of section 3 on architecture, but it's so important that I'm putting it as its own top-level section.

Out of all of the many jQuery plugins you've seen, used, or written, how many of them had an accompanying test suite? Not very many because jQuery isn't very amenable to that. But AngularJS is.

In jQuery, the only way to test is often to create the component independently with a sample/demo page against which our tests can perform DOM manipulation. So then we have to develop a component separately and then integrate it into our application. How inconvenient! So much of the time, when developing with jQuery, we opt for iterative instead of test-driven development. And who could blame us?

But because we have separation of concerns, we can do test-driven development iteratively in AngularJS! For example, let's say we want a super-simple directive to indicate in our menu what our current route is. We can declare what we want in our view:

<a href="/hello" when-active>Hello</a>

Okay, now we can write a test:

it( 'should add "active" when the route changes', inject(function() {
    var elm = $compile( '<a href="/hello" when-active>Hello</a>' )( $scope );

    $location.path('/not-matching');
    expect( elm.hasClass('active') ).toBeFalsey();

    $location.path( '/hello' );
    expect( elm.hasClass('active') ).toBeTruthy();
}));

We run our test and confirm that it fails. So now we can write our directive:

.directive( 'whenActive', function ( $location ) {
    return {
        scope: true,
        link: function ( scope, element, attrs ) {
            scope.$on( '$routeChangeSuccess', function () {
                if ( $location.path() == element.attr( 'href' ) ) {
                    element.addClass( 'active' );
                }
                else {
                    element.removeClass( 'active' );
                }
            });
        }
    };
});

Our test now passes and our menu performs as requested. Our development is both iterative and test-driven. 

5. Conceptually, directives are not packaged jQuery

You'll often hear "only do DOM manipulation in a directive". This is a necessity. Treat it with due deference!

But let's dive a little deeper...

Some directives just decorate what's already in the view (think ngClass) and therefore sometimes do DOM manipulation straight away and then are basically done. But if a directive is like a "widget" and has a template, it should also respect separation of concerns. That is, the template too should remain largely independent from its implementation in the link and controller functions.

AngularJS comes with an entire set of tools to make this very easy; with ngClass we can dynamically update the class; ngBind allows two-way data binding; ngShow and ngHide programmatically show or hide an element; and many more - including the ones we write ourselves. In other words, we can do all kinds of awesomeness without DOM manipulation. The less DOM manipulation, the easier directives are to test, the easier they are to style, the easier they are to change in the future, and the more re-usable and distributable they are.

I see lots of developers new to AngularJS using directives as the place to throw a bunch of jQuery. In other words, they think "since I can't do DOM manipulation in the controller, I'll take that code put it in a directive". While that certainly is much better, it's often still wrong.

Think of the logger we programmed in section 3. Even if we put that in a directive, we still want to do it the "Angular Way". It still doesn't take any DOM manipulation! There are lots of times when DOM manipulation is necessary, but it's a lot rarer than you think! Before doing DOM manipulation anywhere in your application, ask yourself if you really need to. There might be a better way.

Here's a quick example that shows the pattern I see most frequently. We want a toggleable button. (Note: this example is a little contrived and a skosh verbose to represent more complicated cases that are solved in exactly the same way.)

.directive( 'myDirective', function () {
    return {
        template: '<a class="btn">Toggle me!</a>',
        link: function ( scope, element, attrs ) {
            var on = false;

            $(element).click( function () {
                if ( on ) {
                    $(element).removeClass( 'active' );
                }
                else {
                    $(element).addClass( 'active' );
                }

                on = !on;
            });
        }
    };
});

There are a few things wrong with this. First, jQuery was never necessary. There's nothing we did here that needed jQuery at all! Second, even if we already have jQuery on our page, there's no reason to use it here; we can simply use angular.element and our component will still work when dropped into a project that doesn't have jQuery. Third, even assuming jQuery was required for this directive to work, jqLite (angular.element) will always use jQuery if it was loaded! So we needn't use the $ - we can just use angular.element. Fourth, closely related to the third, is that jqLite elements needn't be wrapped in $ - the element that is passed to the link function would already be a jQuery element! And fifth, which we've mentioned in previous sections, why are we mixing template stuff into our logic?

This directive can be rewritten (even for very complicated cases!) much more simply like so:

.directive( 'myDirective', function () {
    return {
        scope: true,
        template: '<a class="btn" ng-class="{active: on}" ng-click="toggle()">Toggle me!</a>',
        link: function ( scope, element, attrs ) {
            scope.on = false;

            scope.toggle = function () {
                scope.on = !scope.on;
            };
        }
    };
});

Again, the template stuff is in the template, so you (or your users) can easily swap it out for one that meets any style necessary, and the logic never had to be touched. 

And there are still all those other benefits, like testing - it's easy! No matter what's in the template, the directive's internal API is never touched, so refactoring is easy. You can change the template as much as you want without touching the directive. And no matter what you change, your tests still pass.

So if directives aren't just collections of jQuery-like functions, what are they? Directives are actually extensions of HTML. If HTML doesn't do something you need it to do, you write a directive to do it for you, and then use it just as if it was part of HTML.

Put another way, if AngularJS doesn't do something out of the box, think how the team would accomplish it to fit right in with ngClick, ngClass, et al.

Summary

Don't even use jQuery. Don't even include it. It will hold you back. And when you come to a problem that you think you know how to solve in jQuery already, before you reach for the $, try to think about how to do it within the confines the AngularJS. If you don't know, ask! 19 times out of 20, the best way to do it doesn't need jQuery and to try to solve it with jQuery results in more work for you.

Variant Data Type in Delphi: Precautions while using variant data types in Delphi

Variant Data Type in Delphi: Precautions while using variant data types in Delphi

The Variant data type provides a flexible general purpose data type. It can hold anything but structured data and pointers. Variants are useful in very specific circumstances, where data types and their content are determined at run time rather than at compile time. 

Basically, once you've declared a variant variable such as the following:

var
  V: Variant;
  
you can assign to it values of several different types:

V := 10;
V := 'Hello, World';
V := 45.55;

Once you have the variant value, you can copy it to any compatible-or incompatible-data type. If you assign a value to an incompatible data type, Delphi performs a conversion, if it can. Otherwise it issues a run-time error. In fact, a variant stores type information along with the data, allowing a number of run-time operations; these operations can be handy but are both slow and unsafe.

Why not to use variant data type intensively in Delphi?

In general, you can use variants to store any data type and perform numerous operations and type conversions. But there are penalties in performance, potentials for run time errors and poor code clarity when using Variants. Notice that this goes against the general approach of the Pascal language and against good programming practices. A variant is type-checked and computed at run time. The compiler won't warn you of possible errors in the code, which can be caught only with extensive testing. On the whole, you can consider the code portions that use variants to be interpreted code, because, as with interpreted code, many operations cannot be resolved until run time. This affects in particular the speed of the code.

Notes:

1. Use VarType in conjunction with VarTypeMask to determine the current data types a Variant is set to. 

2. Variant strings cannot be indexed.

Sunday, February 2, 2014

Why to choose Angular JS Javascript Framework for front-end web development?

Why to choose Angular JS Javascript Framework for front-end web development?

AngularJS is quickly becoming the dominant JavaScript framework for professional web development. With the growth and strength of HTML5 and the increasing performance in modern browsers, many JavaScript frameworks have been created to help develop rich client applications. These frameworks/libraries have given developers a huge toolkit to build enterprise complexity into client-side applications. Server side frameworks are becoming a thing of the past and being replaced with applications written in Backbone, Ember, AngularJS, Knockout, etc.

So why am I talking about AngularJS over frameworks/libraries like Backbone, Ember, or Knockout?

For me, the major points of separation in AngularJS’s favor are the following:

1. Good documentation
2. Write less code to do more
3. Backed by Google
4. Good developer community
5. Simple Data-Binding
6. Small footprint

If you’re looking for a robust, well-maintained framework for any sized project, I strongly recommend that you take a look at AngularJS. It can be downloaded for free at AngularJS.org, which also contains a wealth of information, including the full API documentation, as well as numerous examples and tutorials that cover every facet of front-end web development. Following are some reasons why to choose Angular JS Javascript Framework for front-end web development?

1. Angular JS Framework is developed by Google

Angular is built and maintained by dedicated Google engineers. This one may seem obvious, but it’s important to remember that many (not all) frameworks are made by hobbyists in the open source community. While passion and drive have forged frameworks, like Cappucino and Knockout, Angular is built and maintained by dedicated (and highly talented) Google engineers. This means you not only have a large open community to learn from, but you also have skilled, highly-available engineers tasked to help you get your Angular questions answered.

This isn’t Google’s first attempt at a JavaScript framework; they first developed their comprehensive Web Toolkit, which compiles Java down to JavaScript, and was used by the Google Wave team extensively. With the rise of HTML5, CSS3, and JavaScript, as both a front-end and back-end language, Google realized that the web was not meant to be written purely in Java.

AngularJS came about to standardize web application structure and provide a future template for how client-side apps should be developed.

Angular JS is being used by a host of applications, ranging from hobby to commercial products. Adoption of AngularJS as a viable framework for client-side development is quickly becoming known to the entire web development community.

Because AngularJS is built by Google, you can be sure that you’re dealing with efficient and reliable code that will scale with your project. If you’re looking for a framework with a solid foundation, Angular is your choice!

2. Angular JS is equipped with a lot of features 

If you’re familiar with projects, like QUnit, Mocha or Jasmine, then you’ll have no trouble learning Angular’s unit-testing API.

Angular, similar to Backbone or JavaScriptMVC, is a complete solution for rapid front-end development. No other plugins or frameworks are necessary to build a data-driven web application. Here’s an overview of Angular’s stand-out features:

A) REST Easy. RESTful actions are quickly becoming the standard for communicating from the server to the client. In one line of JavaScript, you can quickly talk to the server and get the data you need to interact with your web pages. AngularJS turns this into a simple JavaScript object, as Models, following the MVVM (Model View View-Model) pattern.

B) MVVM to the Rescue! Models talk to ViewModel objects (through something called the $scope object), which listen for changes to the Models. These can then be delivered and rendered by the Views, which is the HTML that expresses your code. Views can be routed using the $routeProvider object, so you can deep-link and organize your Views and Controllers, turning them into navigable URLs. AngularJS also provides stateless controllers, which initialize and control the $scope object.

C) Data Binding and Dependency Injection. Everything in the MVVM pattern is communicated automatically across the UI whenever anything changes. This eliminates the need for wrappers, getters/setters or class declarations. AngularJS handles all of this, so you can express your data as simply as with JavaScript primitives, like arrays, or as complex as you wish, through custom types. Since everything happens automatically, you can ask for your dependencies as parameters in AngularJS service functions, rather than one giant main() call to execute your code.

D) Extends HTML. Most websites built today are a giant series of <div> tags with little semantic clarity. You need to create extensive and exhaustive CSS classes to express the intention of each object in the DOM. With Angular, you can operate your HTML like XML, giving you endless possibilities for tags and attributes. Angular accomplishes this, via its HTML compiler and the use of directives to trigger behaviors based on the newly-created syntax you write.

E) Makes HTML your Template. If you’re used to Mustache or Hogan.js, then you can quckly grasp the bracket syntax of Angular’s templating engine, because it’s just HTML. Angular traverses the DOM for these templates, which house the directives mentioned above. The templates are then passed to the AngularJS compiler as DOM elements, which can be extended, executed or reused. This is key, because, now, you have raw DOM components, rather than strings, allowing for direct manipulation and extension of the DOM tree.

F) Enterprise-level Testing. As stated above, AngularJS requires no additional frameworks or plugins, including testing. If you’re familiar with projects, like QUnit, Mocha or Jasmine, then you’ll have no trouble learning Angular’s unit-testing API and Scenario Runner, which guides you through executing your tests in as close to the actual state of your production application as possible.

These are the fundamental principles that guide AngularJS to creating an efficient, performance-driven, and maintainable front-end codebase. As long as you have a source for storing data, AngularJS can do all of the heavy lifting on the client, while providing a rich, fast experience for the end user.

3. You can learn Angular JS easily

Getting started with AngularJS is incredibly easy. With a few attributes added to your HTML, you can have a simple Angular app up in under 5 minutes!

1. Add the ng-app directive to the <html> tag so Angular knows to run on the page:

<html lang="en" ng-app>

2. Add the Angular <script> tag to the end of your <head> tag:

<head>
 <script src="lib/angular/angular.js"></script>
...
</head>

3. Add regular HTML. AngularJS directives are accessed through HTML attributes, while expressions are evaluated with double-bracket notation:

<body ng-controller="ActivitiesListCtrl">
  <h1>Today's activities</h1>
  <ul>
   <li ng-repeat="activity in activities">
     {{activity.name}}
   </li>
  </ul>
</body>
</html>

Conclusion

I have enjoyed developing with AngularJS. I hope this post has, at the very least, convinced you to spend a couple of hours playing with AngularJS.

To start, spend some time going through the AngularJS tutorial. Then create your own Custom AngularJS Plunker and see how quickly client-side development can be. As I said at the beginning, AngularJS has a really good community and very clean documentation, which goes into much more detail than this post. Thanks to the AngularJS team for developing this framework.

Saturday, February 1, 2014

Delphi Basic and Advanced Interview Questions and Answers

Delphi Basic and Advanced Interview Questions and Answers

Have you got a call for Delphi interview? Must prepare following Delphi interview questions and answers. These Delphi interview questions and answers cover basic as well as many advanced questions. Many of these interview questions can be asked from you depending upon your experience in Delphi and the projects you have done in Delphi. These Delphi interview questions cover basic introduction of Delphi, OOPS concepts in Delphi, database connectivity in Delphi, environment setup steps, handling with DLLs, Handling Indy clients and mail protocols, third party components like reporting tools, UI tools, error tracking tools etc., unicode support in Delphi, File handling concepts in Delphi and much more.

1. What do you know about Delphi Programming Language? Why and where Delphi is it used? What is happening new in Delphi nowadays? What are the latest versions of Delphi? What is new in latest versions of Delphi?

These are the introductory questions about Delphi programming language which every Delphi developer should know. You should remain updated what's happening latest in Delphi world. You can visit Embarcadero official website to gather more info about Delphi.


Delphi XE5 is the latest version. You can read about its features on Embarcadero website.

2. What is RAD Studio? What is VCL, Firemonkey, Object Inspector, StackTrace? What are the various short-cuts for Run, Step Over, Trace Into, Object Inspector, opening dfm files from pas file and vice-versa? 

RAD Studio is the IDE for Delphi programming language. Earlier it was Borland Studio. If you use Delphi intensively every day, you should be knowing about Visual Component Library (VCL), Firemonkey, Difference between VCL and Firemonkey, use of object inspector and all the short-cuts used in the IDE.


3. Write down a simple program in Delphi to show "Hello World" message with proper syntax.

The main motive behind this simple program is that the interviewer wants to know whether you know about various sections of units like uses, interface, implementation etc. Before going for interview, you should prepare some sample and simple programs in Delphi so that you can explain them well when asked. Uses after implementation - cyclic/circular reference


4. What are the various file extensions used in Delphi? or What are various types of files in Delphi?

Variuos file extensions in Delphi are .pas, .dfm, .dcu, .dpk, .dpr, .dproj, .bpl etc. You should also know the full forms and importance of these extensions in Delphi project. Read complete answer 

5. How do we put comments in Delphi for single line as well as for a block? Can we put comments in dfm file? If yes, then how?

Single line comments: //
Block comments: {  }
You cannot put comments in dfm file as it is meant for designing purpose only.

6. What are various access specifiers in Delphi? What is Published? Where is it used? What is the difference between Public and Published? 

Private, Public, Protected and Published are the various access specifiers in Delphi. Published access specifier is used to expose the data at design time in the Object Inspector.


7. How Constructors and Destructors are implemented in Delphi? What is Inherited keyword? Is it necessary for a class to have constructor or destructor?

Constructors are used to create the instances and destructors are used to destroy the instances and free up the memory. Read complete article 

8. How Inheritance, Polymorphism, Overloading, Abstraction concepts are implemented in Delphi? Does Delphi support Multiple Inheritance? How Multiple inheritance is implemented in Delphi? What is the difference between Abstract Class and Interfaces?

Prepare you general OOPS concepts and also relate them with Delphi. Do prepare sample Delphi programs to implement above OOPS concepts like Inheritance, types of inheritances, Polymorphism, Overloading and Overriding, Abstract classes and interfaces etc.

9. How Exception Handling is implemented in Delphi?

You should be able to write down a simple program to explain the try, except and finally blocks and their usage.

10. What are the packages in Delphi? What are design time and runtime packages in Delphi and what is the difference between them? What is difference between DLL and BPL?


11. What is TStringList? When and why is it used? What are its advantages? Explain with simple example.


12. What is datagrid, dataview, datasource, dataset and database components in Delphi and how they are linked to each other? Do you know how locking is done in Delphi? What is BeginUpdate and EndUpdate? What is EnableControls and DisableControls in Dataset? What is the difference between dbExpress, dbGo and BDE in Delphi? Why to use dbExpress?


13. How Query component is used in Delphi for SELECT, UPDATE, DELETE and INSERT queries? What do you mean by opening and closing a dataset? What is the difference between activating and opening a dataset? What is ExecSQL statement in Delphi? Where is it used?

You should prepare a sample program in which you fire a simple SQL query (Select, Insert, Update and Delete) and show how will these be executed. Google for more help.


14. What is the Transaction Component in Delphi? Why is it used? What is Commit, Rollback and Timeout in Transaction component?

When you have to fire multiple SQL commands at once, you use transaction. When all queries are fired successfully, fire commit else fire rollback. Timeout is the time in milliseconds given for execution of query. Google to read more.

15. How will you implement File Handling in Delphi? How can you open, close, read, write, append and delete files in Delphi? Explain the usage SaveToFile and LoadFromFile functions in Delphi? What is TFileStream and TMemoryStream? What is the difference between them.


16. How will you create LogFiles in Delphi? 


17. How will you read and write data from INI file in Delphi?


18. What are the various event of the Delphi Forms? In which sequence does these events fire? Explain complete life cycle of Delphi Forms?


19. What is OnCloseQuery event in Delphi Form? Why is it used?


20. What is the purpose of Anchors, Align, Margin and AlignWithMargins Form properties? What do you know about Docking?

These all are used for docking and alignments of the components in the Delphi Form. Google for more details. There are good videos available on YouTube to explain these concepts.

21. What is unicode? How does Delphi support unicode? When was the unicode concept introduced in Delphi? What is the difference between Unicode, UTF-8 and UTF-16? Have you migrated any older Delphi version application to unicode version of Delphi? What was your experience? Which problems did you face while code migration?


22. How does Delphi interact with DLLs? What are the various calling conventions in Delphi? How to call DLL functions from Delphi code? What is difference between directives like safecall and stdcall and cdecl? What is HRESULT?


23. How to handle CHM files or help files in Delphi? What is HTMLHelpViewer in Delphi?


24. How to create new process at runtime in Delphi? What is CreateProcess and ShellExecute API calls in Delphi? How these are implemented?



25. Have you ever used Indy Clients in Delphi? What do you know about Socket Programming in Delphi?


26. How to Send Email with Attachments in Delphi XE2 using Indy Clients?


27. How to run XPath Query in Delphi using MSXML DOM?


28. How to create and consume webservices in Delphi using HTTP and SOAP protocols?


29. What are Live Bindings in Delphi?

LiveBindings is a data-binding feature supported by both the VCL and FireMonkey frameworks in RAD Studio. LiveBindings is an expression-based framework, which means it uses bindings expressions to bind objects to other objects or to dataset fields. Read complete article on Embaracdero.

30. What is Oxygene Programming Language? How is it related to Delphi?


32. What steps will you take for Environment Setup in Delphi?

You should know that you can setup the paths for various library files and install packages from Project --> Options, Tools --> Options, Components --> Install Packages etc. 

33. What are the various Build Configurations in Delphi? What is the difference between Release and Debug mode?

Debug mode is used while developing the application and Release mode is used while deployment of the application. Google for more details.

34. Have you used any third party components in Delphi?

There are many third party tools which are used in complex Delphi application for UI, ErrorLog, Reporting etc. For example, QuickReport, Reportbuilder are used for reporting, Devexpress is used for layout and designing etc, Eurekalog is used for error tracking.


35. What can Delphi do that other languages cannot do? 

You can learn what latest is going on in Delphi and what features has Delphi acquired in its latest versions. Delphi can generate native codes for Windows, Linux, Mac OS, Android and iOS. This cross platform support of Delphi makes it a unique programming language. 

36. What should be the output of following conversion?

StrToInt('A') --error
StrToInt('2') --2

Friday, January 31, 2014

Frequently Asked Basic PostgreSQL Interview Questions and Answers

Frequently Asked Basic PostgreSQL Interview Questions and Answers

PostgreSQL is the widely used open source database. If you are preparing for PostgreSQL interview, following list of basic PostgreSQL interview questions and answers might help you in your interview preparation. Following PostgreSQL interview questions and answers cover PostgreSQL basic concepts like feature and advantages of PostgreSQL, key difference between MySQL and PostgreSQL, basic PostgreSQL database administration commands and tools, general PostgreSQL database concepts like Stored Procedures, Functions, Triggers, Cursor, Index, Joins, Subqueries etc. 

1. What is PostgreSQL? What do you know about PostgreSQL?

PostgreSQL, often simply "Postgres", is an open-source object-relational database management system (ORDBMS) with an emphasis on extensibility and standards-compliance. It is released under the PostgreSQL License, a free/open source software license, similar to the MIT License. PostgreSQL is developed by the PostgreSQL Global Development Group, consisting of a handful of volunteers employed and supervised by companies such as Red Hat and EnterpriseDB.

Read more about PostgreSQL on Wikipedia and PostgreSQL official website

2. What are the various features and advantages of PostgreSQL?

This is very basic question and you should be updated on this. You should know why are you using PostgreSQL in your project, what features and advantages does PostgreSQL provide.

Visit official PostgreSQL website to learn more features and advantages of PostgreSQL

3. What are the key differences between MySQL and PostgreSQL? Which Open Source Database to Choose? Which one is best? 

MySQL and PostgreSQL are both free and open source powerful and full-featured databases. You should be able to compare these two databases. Here is the complete article on this.

4. What are the various PostgreSQL database administration commands and tools?

You should know basic PostgreSQL database administration commands like creating users in PostgreSQL, setting up user credentials in PostgreSQL, change / update PostgreSQL user password, check whether PostgreSQL is up and running, commands to create, delete, drop, start, stop, restart, backup, restore PostgreSQL database, getting the list of all databases in PostgreSQL, finding out what version of PostgreSQL is running, PostgreSQL help and history commands, commands to get the list of all the tables in a PostgreSQL database, commands to turn on timing and checking how much time a query takes to execute, commands to see the list of available functions in PostgreSQL etc. Here is the complete article on this topic.

You should also know some of the PostgreSQL administration tools. You can visit Wiki and Stackoverflow to get to know various PostgreSQL administration tools.

5. PostgreSQL database general concepts

Beside all this you should be well aware of datatypes in PostgreSQL, DDL, DML, DCL commands used in PostgreSQL. You should have good knowledge of Indexes, Joins, Subqueries, Stored Procedures, Functions, Triggers, Cursors etc.

I hope you will get benefited by these basic PostgreSQL interview questions and answers.