How To Be A Better Software Developer This Year

February 5, 2014 § Leave a comment

Just sharing this inspirational article from the blog I follow.

How To Be A Better Software Developer This Year

– Simple Programmer

It is easy to get stuck in mediocrity if you are not consciously trying to improve year after year.

We have to constantly be striving to improve our skills and talents, otherwise those abilities can go to waste and degenerate.

Likewise, just striving to “improve” is not good enough either.  We have to have a definite plan for improvement.

In this post, I’ve compiled a list of things you can do this year to improve your skills and make this your best year yet.

#1, Find your biggest weakness

I always try to look for low hanging fruit that I can grab easily when trying to improve anything.  Usually, there is some weakness that could easily be corrected which would provide a huge benefit to you, but you’ve just never got around to fixing it.

For example, when I first moved into my new house, my refrigerator was not holding the temperature correctly.  The fridge would drop down to a very cold temperature and freeze food pretty often.

This was pretty frustrating, but I tried to ignore the problem, because I was too busy.  I kept having to throw out frozen lettuce or other vegetables until one day I decided I had enough and set it on my mind that I would either fix the fridge myself or have it repaired.

It only took me a few hours total worth of work to figure out that a little flap that sent cold air from the freezer to the fridge was broken, and to fix that issue by ordering the right part.  The results were immediate and very gratifying.  By taking that little bit of time out of my week, I saved myself quite a bit of frustration in the future—not to mention saved myself money in both electricity costs and wasted food.

So, why did it take me so long to fix that fridge?

I was always too busy, and the problem never seemed urgent enough to warrant my attention.  (Plus, I didn’t know jack about fridges.)

When I take an inventory of my professional life, I find that I have many “broken fridges” all around my office.  Weaknesses or problems that I could very easily fix, but I’ve just been to busy to get around to it.

Perhaps you have the same problem?  Have you been struggling through using your IDE, because you didn’t take the afternoon to properly learn the keyboard shortcuts that would save you quite a bit of time?

Are you stumbling through some JavaScript library, because you didn’t spend the few hours worth of time it would take to really understand how it works and how to use it properly?

Perhaps you just haven’t taken the time to organize your computer or workflow, because it hasn’t been enough of a pain to be worth your time—even though you know that you are wasting a huge amount of time by being so unorganized?

Now is a good time to look for that low hanging fruit; the easy to fix weakness you can correct this year, which will pay back big dividends.

If you take the time to look around, I’m sure you’ll find a few.

#2 Learn something new

Because our field changes so rapidly, it is very important to be learning the next thing before you need to rely on the skills to use it.

It isn’t always possible to predict what the next thing will be, but getting into the practice of learning new things will expand your capacity to learn things quickly and give you a much wider perspective of the field in general.

One of the biggest expansions of my abilities as a software developer came when I took a consulting gig leading a team of Java developers after having spent years programming in C# and .NET.  I was very reluctant to take the position, because I felt that I would be progressing backwards instead of forwards, but I couldn’t have been more wrong.

I already knew some Java, but I hadn’t really studied the language and I didn’t know much about the environment and tools Java developers use.

This experience forced me to grow and really expanded my abilities, not just in Java, but in C# as well, because it forced me to look at things from a different perspective.

It is really easy to get stuck in a rut and stick with what we already know, but sometimes you can get a huge benefit by getting a bit out of your comfort zone and learning something completely new.

Try learning a new programming language this year or an entire new programming environment.  Try your hand at mobile development, if you’ve never done it before, or learn something else that will challenge you and expand your horizons.

 

#3 Make new friends

Every year I talk to hundreds of software developers through email or at conferences and code camps, but my software developer life wasn’t always so social.

I didn’t really see the point in reaching out and being part of the community; after all, I was a software developer, my job is to write code, isn’t it?

But, all of us have very limited worlds, myself included. We need the experiences and influences of others to expand our viewpoints and see things that we don’t have the capabilities to see on our own.

Think about it this way.  How far would you have gotten in learning any pursuit if you were completely self-taught and couldn’t rely on any books, conversations, or search engines to expand your knowledge?  Probably not very far at all.

It is important to reach out and talk to other software developers—and not just your coworkers—so that you get a mixing of ideas and viewpoints which will force you to grow.

Doing this may be as simple as starting your own blog to share your experiences and interact with others who comment on or read your posts.

You can also join a user group or attend a code camp or conference, which will give you ample opportunities to meet new people and exchange ideas.

There is also a huge emotional reward in giving back.  If you have some experience that you can share with others, doing so is likely to make you feel really good about yourself and provide a benefit to someone who could use your help.

If you are feeling down in the dumps or depressed, one instant cure is to do something nice for someone else.  Is there a developer you know that could use your help?

#4 Set a course

If you don’t know where you are headed in your career, there is no better time to figure it out than now.

So many developers drift aimlessly through their careers without thinking about where they want to be and what they want to become.

It is not enough to say that you want to become a good software developer or programmer—you need to set a definite direction that you are progressing towards.

With a clear goal in mind, your mind will employ the power of your subconscious mind to help you achieve that goal.  Without one, you’ll just float adrift never reaching any real destination.

(By the way, this is one of the most powerful realizations you can discover in life.  Once you learn to harness the power of your subconscious mind, you’ll be amazed at what you can accomplish.  The book that explains it better than I can here, is Psycho-Cybernetics, I highly recommend it.  One of those “must read” books.)

This doesn’t mean you have to chart out your life and decide where you will be in 20 years, but it does mean that you should at least have a plan of what you intend to accomplish by the end of this year and at least have some kind of destination out a bit further than that.

It is really worth taking that time to sit down and think about what you want to accomplish.  Don’t even worry about how you will accomplish it. It is much more important to focus on the what.  The how will come automatically once you tackle the hard problem of what.

 

Make this your best year yet!

Hopefully this post gave you some ideas you can use to help you to move the ball forward this year and really move towards some clear and definite goals.

One of my goals this year is to finish building my course on How to Market Yourself as a Software Developer.  I plan to include topics like the one in this post to help you chart a definite plan to market your skills and really boost your career.

It is only available for limited pre-order now while I am getting together a group of early adopters that will help me shape the rest of this course, but if you want to know when it will be released or you are just interested in more posts and software developer career advice, like this one, sign up here and I’ll keep you updated.

What are you doing this year to become a better software developer?

On Vacation

February 5, 2014 § Leave a comment

Hello guys,

I got married last here in late Oct 2013. So I was out of action. Beginning from I have lot of articles I need to publish. MVC4 , WCF & SOLR stuff.

See you guys soon

Thanks

 

 

SQL SERVER – Disadvantages (Problems) of Triggers

August 7, 2013 § 1 Comment

SQL SERVER – Disadvantages (Problems) of Triggers – Pinal Dave

 

One of my team member asked me should I use triggers or stored procedure. Both of them has its usage and needs. I just basically told him few issues with triggers. This is small note about our discussion.

Disadvantages(Problems) of Triggers

  • It is easy to view table relationships , constraints, indexes, stored procedure in database but triggers are difficult to view.
  • Triggers execute invisible to client-application application. They are not visible or can be traced in debugging code.
  • It is hard to follow their logic as it they can be fired before or after the database insert/update happens.
  • It is easy to forget about triggers and if there is no documentation it will be difficult to figure out for new developers for their existence.
  • Triggers run every time when the database fields are updated and it is overhead on system. It makes system run slower.

I do not use triggers. In my whole career I am able to get my work done using Stored Procedures instead of Triggers. (Implementation and Architecture changes are required if either of is to be used to support business logic).

Building Search Interface Using Apache Solr in .NET

August 7, 2013 § 1 Comment

A quick, granular and accurate search interface is of prime importance for most web applications today. Many have traditional search interfaces where the scope of search is restricted to specific fields; thus limiting the ability to get relevant search results. However, most commercial web sites will require an advanced search interface that will index the content of documents, build complex queries based on multiple criteria and fetch maximum results. In this paper, we introduce the Apache Solr Search Engine that will, most importantly, provide content search, explain how to construct queries involving multiple search criteria using Solr and integrate with the application to build a quicker, accurate and more refined search interface.

Apache Solr is an open source enterprise search server, based on the Lucene Java search library, with XML/HTTP and JSON APIs. It runs in a Java servlet container, such as Tomcat. Input to Solr is the document with optional metadata. We put documents in it (called as indexing) via XML, JSON, CSV or binary over HTTP. We query it via HTTP Get and receive XML, JSON, CSV or binary result. It is architected to deliver very fast search operations across wide variety of data.

Features

  • Advanced full-text search – Users can search for one or more words or phrases in the content of documents, specific fields, or combinations of one or more fields, thus providing results that match user’s interests.
  • Faceted Search – User can narrow down the search results further by applying filters on the fields (numeric, date fields, unique fields) if the user wishes to drill down. Thus providing categorized search.
  • Sort – User can prioritize the search results based on field count.
  • Pagination – User can display the search results in pages of fixed size.
  • Hit-Term Highlighting – Provides highlighting of the search keyword in the document.
  • It is optimized for high-volume web traffic.
  • It supports rich Document Parsing and Indexing (PDF, Word, HTML, etc.)
  • Admin UI – It has a very simple and user-friendly interface for designing and executing queries over the data.
  • Caching – It caches the results of filter queries, thus delivering faster search operations.

Architecture

Diagram

The above block diagram shows the sequence of actions for uploading documents to Solr and executing Search queries as per specific search criteria to get the relevant matches.

Building Search Interface for Your Web Application:

We assume that Solr is configured and running. User will be required to know the Solr endpoint.

For more information on installing, configuring and running Solr, go here.

We propose a generic search interface that can be implemented to search any application specific entity that is indexed by Solr. Search method accepts the SearchParameters and returns the SearchResult of generic type <T>.



public interface ISearch<T>

    {

        SearchResult<T> Search (SearchParameters parameters);

    }

 

Let us see how the SearchParameters look like and how they are constructed.

public class SearchParameters {
        public const int DefaultPageSize = 4;

        public SearchParameters () {
SearchFor = new Dictionary<string, string>();
Exclude = new Dictionary<string, string>();
SortBy = new List<SortQuery>();
FilterBy = new List<FilterQuery>();
PageSize = DefaultPageSize;
PageIndex = 1;
        }

        public string FreeSearch { get; set; }
        public int PageIndex { get; set; }
        public int PageSize { get; set; }
        public IDictionary<string, string> SearchFor { get; set; }
        public IDictionary<string, string> Exclude { get; set; }
        public IList<SortQuery> SortBy { get; set; }
        public IList<FilterQuery> FilterBy{ get; set; }
        }
  }
  • SearchFor : We add the advanced full-text parameters to this dictionary in the following pattern:
Key – Name of field Value – Word/phrase
Title Azure, “cloud computing”
tags Azure, “cloud computing”
  • Exclude: These are parameters to be excluded in the advanced full-text Search added to a dictionary.
Key – Name of field Value – Word/phrase
Title business
tags business
  • SortBy: This is a List of SortQuery items. FieldName will map to the field on which the sorting needs to be done. Order will indicate the SortOrder (Ascending/Descending)
public class SortQuery
    {
        public string FieldName { get; set; }
        public SortOrder order { get; set; }
    }
public enum SortOrder
        {
            Ascending,
            Descending,
        }
FieldName order Description
Like _integer Descending Will sort the search results in descending order of number of Likes
  • FilterBy: This is a list of FilterQuery items.
public class FilterQuery

    {

        public string FieldName {get; set;}

        public string LowerLimit { get; set; }

        public string UpperLimit { get; set;}

        public string Value { get; set; }

        public string DataType { get; set; }

    }
  • FieldName = The field on which filtering needs to be done
  • Value = Value of the filter field
  • DataType = If filtering values are restricted to a particular range, this will indicate datatype of the filter field
  • LowerLimit = If filtering values are restricted to a particular range, this will indicate lowerlimit of the filter field
  • UpperLimit = If filtering values are restricted to a particular range, this will indicate upperlimit of the filter field

Table1

  • PageSize: This is used for pagination to specify number of search results per page.
  • PageIndex: This is used for pagination to specify the offset for query’s results set. It will instruct Solr to display results from this offset.

Implementing search interface:

SolrNet is a free Open Source API that can be integrated with your .NET web application to build queries programmatically and execute them over Solr.

Creating Solr search result entity

We first create a class with properties that will map to the fields returned in the Solr search result. To identify the fields we will fire the search query in Solr Admin UI or contact the administrator.

For example:
To get search results for keyword “twitter” we will enter the keyword in the “Query String” textbox of Solr Admin UI and hit the Search button.

A query such as http://endpoint/solr/select?q=twitter&fq=&start=0&rows=10 will appear in the browser which is the search query.

The response will be XML with nodes for each search result. Users can identify the fields returned from this response and create the properties accordingly.

SolrNet.Attributes namespace contains attributes to map fields from Solr search result to entity. These attributes can be used to augment existing application entity or create a parallel entity.

Example:

public class Product

 {

        [SolrUniqueKey("company_id_text")]

        public string CompanyId { get; set; }

        [SolrField ("product_count_integer")]

        public int ProductCount { get; set; }

        [SolrField("title_text")]

        public string Title { get; set; }

        [SolrField("created_on_datetime")]

        public DateTime CreatedOn { get; set; }

        [SolrField("downloadable_boolean")]

        public bool Downloadable { get; set; } 

}

SolrUniqueKey uniquely identifies the document. In database terms, it is the primary key. So users should choose to map a SolrUniqueKey in case the field is unique for each document, or SolrField can be used. The property name must exactly map to the field name in the Solr output XML.

Initialization:

using SolrNet;

public class Search Product: ISearch<Product>

{

static ISolrReadOnlyOperations< Product > solr;

static SolrConnection connection;

        static Search Product ()

        {                      

            connection = new SolrConnection("solrendpoint");          

            Startup.Init< Product >(connection);

           Solr = ServiceLocator.Current.GetInstance<ISolrReadOnlyOperations< Product>>();

        }

}

The above code snippet will initialize the SolrConnection. We also instantiate ISolrReadOnlyOperations<T> variable that we will use to build the Solr query. Here Product refers to the type of search result to be fetched.

Building Queries:

public SearchResult<Product> Search(SearchParameters parameters)

        {

            int? start = null;

            int? rows = null;

            if (parameters.PageIndex > 0)

            {

                start = (parameters.PageIndex - 1) * parameters.PageSize;

                rows = parameters.PageSize;

            }

            var matchingProducts = solr.Query(BuildQuery(parameters), new QueryOptions

            {

                FilterQueries = BuildFilterQueries(parameters),

                Rows = rows,

                Start = start,

                OrderBy = GetSelectedSort(parameters),

            });

            return new SearchResult< Product>(matchingProducts)

            {

                TotalResults = matchingProducts.NumFound,

            }}

The Query() method has the following prototype:

SolrQueryResults<T> Query (ISolrQuery query, QueryOptions options); 
  • Query = the advanced full-text search query
  • Options = Filter, Sort, Pagination options.
  • Returns SolrQueryResults of type T. In our case T = Product.
  • In the above code,FilterQueries = the filter query to be executed on the search results obtained after applying the full-text search query.
  • OrderBy = the sort query to be executed on the search results obtained after filtering.
  • Rows = for pagination specifies the number to search results to be returned.
  • Start = for pagination specifies the offset in the Solr response from where the results will be fetched.

Build advanced full-text search query:

public ISolrQuery BuildQuery(SearchParameters parameters)

        {

            if (!string.IsNullOrEmpty(parameters.FreeSearch))

                return new SolrQuery(parameters.FreeSearch);

            AbstractSolrQuery searchquery = null;

            List<SolrQuery> solrQuery = new List<SolrQuery>();

            List<SolrQuery> solrNotQuery = new List<SolrQuery>();

            foreach (var searchType in parameters.SearchFor)

            {

                solrQuery.Add(new SolrQuery(string.Format("{0}:{1}", searchType.Key,   searchType.Value)));

            }

            if (solrQuery.Count > 0)

                searchquery = new SolrMultipleCriteriaQuery(solrQuery, SolrMultipleCriteriaQuery.Operator.OR);

            foreach (var excludeType in parameters.Exclude)

            {

                solrNotQuery.Add(new SolrQuery(string.Format("{0}:{1}", excludeType.Key,  excludeType.Value)));

            }

            if (solrNotQuery.Count > 0)

            {

                searchquery = (searchquery ?? SolrQuery.All) - new SolrMultipleCriteriaQuery(solrNotQuery, SolrMultipleCriteriaQuery.Operator.OR);

            }

            return searchquery ?? SolrQuery.All;

        }
  • new SolrQuery(“fieldname : value”) = This class will create a SolrQuery for a full-text search of the given word/phrases in the fieldname
  • new SolrMultipleCriteriaQuery(solrQuery, Operator (AND/OR etc.)) = This class will apply the respective boolean operator on a list of solr queries.
  • SolrQuery.All = This will return all the documents in Solr without applying any search query.

Build Filter Queries:

public ICollection<ISolrQuery> BuildFilterQueries(SearchParameters parameters)

        {

            List<ISolrQuery> filter = new List<ISolrQuery>();

            foreach (var filterBy in parameters.FilterBy)

            {

                if (!String.IsNullOrEmpty(filterBy.DataType) &&  filterBy.DataType.Equals(Constants.DATE_DATATYPE))

                {

                    DateTime upperlim = Convert.ToDateTime(filterBy.UpperLimit);

                    DateTime lowerlim = Convert.ToDateTime(filterBy.LowerLimit);

                    if (upperlim.Equals(lowerlim))

                    {

                        upperlim = upperlim.AddDays(1);

                    }

                    filter. Add(new SolrQueryByRange<DateTime>(filterBy.FieldName, lowerlim,

                        upperlim));

                }

                else

                {

                    string[] filterValues;

                        if (filterBy.Value.Contains(";"))

                        {

                            filterValues = filterBy.Value.Split(';');

                            List<SolrQueryByField> filterForProduct = new List<SolrQueryByField>();

                            foreach (string filterVal in filterValues)

                            {

                               filterForProduct.Add(new SolrQueryByField(filterBy.FieldName, filterVal) { Quoted = false });

                            }

                            filter.Add(new SolrMultipleCriteriaQuery(filterForProduct, SolrMultipleCriteriaQuery.Operator.OR));

                        }

                        else

                        {

                            filter.Add(new SolrQueryByField(filterBy.FieldName, filterBy.Value));

                        }

                    }

                }           

            return filter;

        }

There are 2 types of filters:

  • SolrQueryByField:
new SolrQueryByField(filterBy.FieldName, filterVal) { Quoted = false })

This accepts the fieldName and filter value. Quoted = false indicates that character escaping is disabled.

  • SolrQueryByRange:
new SolrQueryByRange<DateTime>(filterBy.FieldName, lowerlim, upperlim) 

We use SolrQueryByRange when our filter values fall between some ranges. This needs the datatype of the field. DateTime in our case. The fieldname for filter, its lower limit and upper limit.

Build Sort Queries:

private ICollection<SortOrder> GetSelectedSort(SearchParameters parameters)

        {

            List<SortOrder> sortQueries = new List<SortOrder>();

            foreach (var sortBy in parameters.SortBy)

            {

                if (sortBy.order.Equals(SortQuery.SortOrder.Ascending))

                    sortQueries.Add(new SortOrder(sortBy.FieldName, Order.ASC));

                else

                    sortQueries.Add(new SortOrder(sortBy.FieldName, Order.DESC));

            }

            return sortQueries;

        }

SortOrder class will accept the fieldName to be sorted on along with the Sort Order (Ascending/Descending).

Relevance Score

Solr will by default order the search results based on the relevancy score that is calculated to determine how relevant a given Document is to a user’s query. The more times a query term appears in a document relative to the number of times the term appears in all the documents in the collection, the more relevant that document is to the query. Thus the priority of the search results will always be on track unless one explicitly gives a sort parameter in the search query.

Conclusion

This paper has provided a detailed description of the search options available with Apache Solr and will hopefully serve as a thorough guide in deciding on the search parameters, constructing queries and for building an Advanced Search interface.

What are the Differences Between Relational and Graph Databases?

July 15, 2013 § 3 Comments

What are the Differences Between Relational and Graph Databases?

Say “database” to most people, and the concept of an organized collection of data, neatly stored in rows and columns of tables comes to mind. This concept of a fixed schema, where each row is a collection of attributes, is the basis for relational databases and the querying languages, such as SQL (Structured Query Language) used to interact with the stored data since the earlier 1970’s.

In the last 15 years however, there are several industries where the amount of data being generated greatly exceeds the ability for relational databases to handle it. Companies like Google and Amazon have long been generating massive amounts of data using countless numbers of servers. With the resulting data spread across multiple machines, traditional relational SQL JOIN operations are just not possible.

Graph Databases

Enter graph databases, which are defined as any storage system that provides index-free adjacency. What this means is that every element in the database contains a direct link to its adjacent element. No index lookups are required; every element (or node) knows what node or nodes it is connected with, this connection is called an edge. This allows graph database systems to utilize graph theory to very rapidly examine the connections and interconnectedness of nodes – and how Netflix can recommend videos for you.

The power of the edge allows a graph database to find results in associative data sets – data where information is the aggregation of links between nodes – faster than relational databases. Graph databases can scale more naturally to large data sets and to datasets with changing or on-the-fly schemas. On the other hand, relational databases are still better at performing the same operation on large numbers of identical data. When you want your bank balance, you don’t want a rapid list of all your transactions – just your bottom line.

The use of graph databases is rapidly spreading to many applications through the use of mixed-database approaches, where a graph search is used to identify the extent of the data, and a subsequent relational search is used to provide the detailed analytics. While this approach presently involves developing (and supporting) two database structures, it yields rapid response and targeted data analysis. Some solutions present the graph results to users while the analytics are being pulled and crunched; other systems serve up old results while the new results are being calculated. How analytics and associations coexist is one of the considerations that must be made when architecting your solution.

So is a graph database in your future? If a third or more of your relational tables describe links between data elements, your database is heavily associative, and can be a graph database candidate. The final decision requires a complete analysis of how the data is being used, volume and growth patterns, and not just a review of table structures. If your data is used for statistical analysis, data mining and exploration, or operational research, the relational database approach is still at least part of the architectural solution.

Next Top Data Model by Ian Plosker

July 4, 2013 § 1 Comment

Summary
Ian Plosker shares a number of techniques for establishing the data query patterns from the outset of application development, designing a data model to fit those patterns.

Next Top Data Model

 

Conclusion

Interesting discussion on choosing data model. Its really important to understand what our application want. Very good presenation

A Google Gaming Console? It’s Madness!

June 29, 2013 § Leave a comment

A Google Gaming Console? It’s Madness!

Google and Apple would be nuts to dive into the gaming console business and would both be better off focusing on tablets.

google logo

Bubbling up in today’s news stream is a report thatGoogle wants to get into the game console businessand that Apple may too.

In a column earlier this week I concluded that unless a big spender willing to throw money away comes along, nothing will change. It’s a duopoly. That is, unless you think the business can be sustained by the Angry Birds franchise.

Let’s dissect some of these developments. To begin, the Google threat is a rumor. If it becomes more than a rumor it will become a pipe dream.

Both Google and Apple should be doing the logical thing: turn the tablet into a game machine. The idea is to sell tablets. What is the point of adding a game console unless it is nothing more than an HDTV interface?

The Nintendo Wii U comes with a small, dedicated tablet on which you can actually play a game without a TV or screen. I’m sure this attracted the attention of the folks at Google and Apple.

But instead of copying Nintendo while competing with Xbox and PlayStation, both Apple and Google should be sponsoring some development work designed to create a killer tablet-based game. This is where the future lies, not in clunky game consoles that many people only use for Netflix.

Also, does anyone think that Google and Apple are serious? Are these companies sincere or are they just scrambling for something to make it look as if they are growth companies?

I hope that none of this is true. The console side of the tech industry is a zombie. It’s not as if I don’t expect to see Halo 12 and Call of Duty 14 years from now, but how drab can the future be if you are looking at a screen carrying a virtual gun and roaming around some battlefield waiting for some action? If the economy ever corrects, nobody is going to have time for any of this. And if they do, then it’ll be on a tablet.

If Google or Apple indeed brings out a gaming console, I’ll be stunned. But if they create some sort of tablet add-on that has the controls similar to the Nintendo Wii U, which then hooks up to a tablet, then I’d say fine, at least this sort of retro idea sells more tablets. If instead neither company plans on doing anything and this is all part of a scheme to harass Microsoft, then great. But an actual game console based on iOS and Android? It’s madness.