Tuesday, July 16, 2013

Some of the Anti patterns

Anti Patterns
It is exactly opposite of software design Patterns. Some the well known  anti patterns are the problems which software industry faces. Anti patterns are out comes of following bad practices, over engineering, implementation of design patters without having enough knowledge of patterns or not understanding the context of problem.  

Anti patterns are real world experience of understand recurring problems of software industry. It helps to recognize problems and understand the cause of it. They are also a bridge between understanding architectural concepts and its real world implementations.

There are three categories of software anti patterns like  
1. Software development anti patterns
2. Software architectural anti patterns
3. Software Project Management  anti patterns.

Some of the development Anti patterns

1. God Object ( Monster Object):

If some object know too much or does too much called a God object. Which is opposite to Single responsibility Principle  one of the SOLID principal. 

If Problem is big it is very hard or tough to resolve it. So if we divide it in a smaller parts of problem it is easy to solve them. So in software engineering if we create and object with single responsibility, we should divide one big task in to smaller separate responsibility (class) so when any change or problem occur we have to change smaller class and also we have to test only one smaller class after change.  

In case of God object, It is very tough to maintain it. It is also very tough to test it. If we change something small thing of a God object we have to test the whole object functionality.  

Symptoms: 
  • Single class with many attributes & operation.
  • Controller class with simple data object class
  • Lack of Object oriented design
  • A migrated legacy design
   
Consequences:
  • Tough to maintain 
  • Tough to test
  • Lost all object oriented advantage
  • To complex to reuse 
  • Expensive to load.
   
2. Copy and Paste programming.



This is favorite of any developer including me. Ctrl + C, Ctrl + V is part of any developers life. It is good if you are doing it from external sources to boost your development with good understanding of it, but it becomes Anti pattern when you do it with your own code.  If you are doing copy and paste of your own code then it is an Anti pattern.
 
Symptoms:

  • Similar code found in an Application.
  • When client change the requirement, You have to change code at more then 1 places.
  • Bug found by Tester and developer has fixed it but it reoccurs ( because not fixed all the places)
  • No code review done by experience programmer or lead.

 Causes:

  • It has huge maintenance efforts, If some requirement changed, developer has to change code to many places.
  • Developer is lack of knowledge of software development principals like OOPs, SOLID, DRY (Do not Repeat Yourself).
  • Lack of forward thinking among developers. 
  • A "Not Invented Here" syndrome applied to development environment.  Meaning development environment do not adopt external tools and employ reinvent the wheel. 
  • Developers are lack of knowledge of  new easy technology available. 

Whenever you as an developer come across the situation to copy and paste your own code, Stop that and find the opportunity to write it with common class or component and make it reusable with loose coupling.

3. Functional Decomposition

In Object oriented environment, If someone write code in procedural programming way, Just decompose Main methods in to several private methods only then it becomes Anti Patterns. So instead of writing different classes or design class architecture according to different tasks, if code is just decomposed in to private methods only then it is an anti pattern.  This is mostly done by experience programmer in procedural languages like  C and shifted to Object oriented programming language.

Symptoms:

  • All Class attributes are private and used in one class.
  • Degenerated architecture and missed most object oriented architecture
  • No use of re usability
  • Very tough to do documentation or design class diagram.


Causes:

  • Lack of object oriented design understanding. 
  • Lack of architecture enforcement.




4. Spaghetti code:

Spaghetti code is a code meaning unstructured code, written by developer who is less experienced or lake of knowledge of Object oriented programming. Code written like a procedural programming.  This kind of code, developer himself  can't understand his own code what he has written after few days.

code looks like spaghetti.


Symptoms:

  •  Code is not much reusable.
  •  Flow of execution dictate by objects and not the client of the objects
  •  Minimum relationship exits between objects.
  •  Code is not a unit testable. or end up writing too many integration tests.
  • No any advantage of Object oriented programming.
  • Very difficult to maintain. so maintenance cost is higher then re write new from the scratch.


Causes

  • Code written by inexperience in object oriented programming developer.
  • No design prior to development
  • No effective code review.

Whenever experience developer see this kind of code, he smells it and find opportunity to re factor it.

There are some other anti patterns are also there. I will understand it thoroughly and edit this blog.

Friday, June 7, 2013

Some Interview questions by Scott Hansleman

As I follow him very closely and don't want to loos these questions from his blog. I just copied here.  I also has to prepare some of them.   
  • What is something substantive that you've done to improve as a developer in your career? 
  • Would you call yourself a craftsman (craftsperson) and what does that word mean to you? 
  • Implement a <basic data structure> using <some language> on <paper|whiteboard|notepad>. 
  • What is SOLID? 
  • Why is the Single Responsibility Principle important? 
  • What is Inversion of Control? How does that relate to dependency injection? 
  • How does a 3 tier application differ from a 2 tier one? 
  • Why are interfaces important? 
  • What is the Repository pattern? The Factory Pattern? Why are patterns important? 
  • What are some examples of anti-patterns? 
  • Who are the Gang of Four? Why should you care? 
  • How do the MVP, MVC, and MVVM patterns relate? When are they appropriate? 
  • Explain the concept of Separation of Concerns and it's pros and cons. 
  • Name three primary attributes of object-oriented design. Describe what they mean and why they're important. 
  • Describe a pattern that is NOT the Factory Pattern? How is it used and when? 
  • You have just been put in charge of a legacy code project with maintainability problems. What kind of things would you look to improve to get the project on a stable footing? 
  • Show me a portfolio of all the applications you worked on, and tell me how you contributed to design them. 
  • What are some alternate ways to store data other than a relational database? Why would you do that, and what are the trade-offs? 
  • Explain the concept of convention over configuration, and talk about an example of convention over configuration you have seen in the wild. 
  • Explain the differences between stateless and stateful systems, and impacts of state on parallelism. 
  • Discuss the differences between Mocks and Stubs/Fakes and where you might use them (answers aren't that important here, just the discussion that would ensue). 
  • Discuss the concept of YAGNI and explain something you did recently that adhered to this practice. 
  • Explain what is meant by a sandbox, why you would use one, and identify examples of sandboxes in the wild. 
  • Concurrency 
  • What's the difference between Locking and Lockless (Optimistic and Pessimistic) concurrency models? 
  • What kinds of problems can you hit with locking model? And a lockless model? 
  • What trade offs do you have for resource contention? 
  • How might a task-based model differ from a threaded model? 
  • What's the difference between asynchrony and concurrency? 
  • Are you still writing code? Do you love it? 
  • You've just been assigned to a project in a new technology how would you get started? 
  • How does the addition of Service Orientation change systems? When is it appropriate to use? 
  • What do you do to stay abreast of the latest technologies and tools? 
  • What is the difference between "set" logic, and "procedural" logic. When would you use each one and why? 
  • What Source Control systems have you worked with? 
  • What is Continuous Integration? Have you used it and why is it important? 
  • Describe a software development life cycle that you've managed. 
  • How do you react to people criticizing your code/documents? 
  • Whose blogs or podcasts do you follow? Do you blog or podcast? 
  • Tell me about some of your hobby projects that you've written in your off time. 
  • What is the last programming book you read? 
  • Describe, in as much detail as you think is relevant, as deeply as you can, what happens when I type "cnn.com" into a browser and press "Go". 
  • Describe the structure and contents of a design document, or a set of design documents, for a multi-tiered web application. 
  • What's so great about <cool web technology of the day>? 
  • How can you stop your DBA from making off with a list of your users’ passwords? 
  • What do you do when you get stuck with a problem you can't solve? 
  • If your database was under a lot of strain, what are the first few things you might consider to speed it up? 
  • What is SQL injection? 
  • What's the difference between unit test and integration test? 
  • Tell me about 3 times you failed. 
  • What is Refactoring ? Have you used it and it is important? Name three common refactorings. 
  • You have two computers, and you want to get data from one to the other. How could you do it? 
  • Left to your own devices, what would you create? 
  • Given Time, Cost, Client satisfaction and Best Practices, how will you prioritize them for a project you are working on? Explain why. 
  • What's the difference between a web server, web farm and web garden? How would your web application need to change for each? 
  • What value do daily builds, automated testing, and peer reviews add to a project? What disadvantages are there? 
  • What elements of OO design are most prone to abuse? How would you mitigate that? 
  • When do you know your code is ready for production? 
  • What's YAGNI? Is this list of questions an example? 
  • Describe to me some bad code you've read or inherited lately. 

What Great .NET Developers Ought To Know

Everyone who writes code

  • Describe the difference between a Thread and a Process? 
  • What is a Windows Service and how does its lifecycle differ from a "standard" EXE? 
  • What is the maximum amount of memory any single process on Windows can address? Is this different than the maximum virtual memory for the system? How would this affect a system design? 
  • What is the difference between an EXE and a DLL? 
  • What is strong-typing versus weak-typing? Which is preferred? Why? 
  • Corillian's product is a "Component Container." Name at least 3 component containers that ship now with the Windows Server Family. 
  • What is a PID? How is it useful when troubleshooting a system? 
  • How many processes can listen on a single TCP/IP port? 
  • What is the GAC? What problem does it solve?

Mid-Level .NET Developer

  • Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming. 
  • Describe what an Interface is and how it’s different from a Class. 
  • What is Reflection? 
  • What is the difference between XML Web Services using ASMX and .NET Remoting using SOAP? 
  • Are the type system represented by XmlSchema and the CLS isomorphic? 
  • Conceptually, what is the difference between early-binding and late-binding? 
  • Is using Assembly.Load a static reference or dynamic reference? 
  • When would using Assembly.LoadFrom or Assembly.LoadFile be appropriate? 
  • What is an Asssembly Qualified Name? Is it a filename? How is it different? 
  • Is this valid? Assembly.Load("foo.dll"); 
  • How is a strongly-named assembly different from one that isn’t strongly-named? 
  • Can DateTimes be null? 
  • What is the JIT? What is NGEN? What are limitations and benefits of each? 
  • How does the generational garbage collector in the .NET CLR manage object lifetime? What is non-deterministic finalization? 
  • What is the difference between Finalize() and Dispose()? 
  • How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization? 
  • What does this useful command line do? tasklist /m "mscor*" 
  • What is the difference between in-proc and out-of-proc? 
  • What technology enables out-of-proc communication in .NET? 
  • When you’re running a component within ASP.NET, what process is it running within on Windows XP? Windows 2000? Windows 2003?

Senior Developers/Architects

  • What’s wrong with a line like this? DateTime.Parse(myString); 
  • What are PDBs? Where must they be located for debugging to work? 
  • What is cyclomatic complexity and why is it important? 
  • Write a standard lock() plus “double check” to create a critical section around a variable access. 
  • What is FullTrust? Do GAC’ed assemblies have FullTrust? 
  • What benefit does your code receive if you decorate it with attributes demanding specific Security permissions? 
  • What does this do? gacutil /l | find /i "Corillian" 
  • What does this do? sn -t foo.dll 
  • What ports must be open for DCOM over a firewall? What is the purpose of Port 135? 
  • Contrast OOP and SOA. What are tenets of each? 
  • How does the XmlSerializer work? What ACL permissions does a process using it require? 
  • Why is catch(Exception) almost always a bad idea? 
  • What is the difference between Debug.Write and Trace.Write? When should each be used? 
  • What is the difference between a Debug and Release build? Is there a significant speed difference? Why or why not? 
  • Does JITting occur per-assembly or per-method? How does this affect the working set? 
  • Contrast the use of an abstract base class against an interface? 
  • What is the difference between a.Equals(b) and a == b? 
  • In the context of a comparison, what is object identity versus object equivalence? 
  • How would one do a deep copy in .NET? 
  • Explain current thinking around IClonable. 
  • What is boxing? 
  • Is string a value type or a reference type? 
  • What is the significance of the "PropertySpecified" pattern used by the XmlSerializer? What problem does it attempt to solve? 
  • Why are out parameters a bad idea in .NET? Are they? 
  • Can attributes be placed on specific parameters to a method? Why is this useful? 

C# Component Developers

  • Juxtapose the use of override with new. What is shadowing? 
  • Explain the use of virtual, sealed, override, and abstract. 
  • Explain the importance and use of each component of this string: Foo.Bar, Version=2.0.205.0, Culture=neutral, PublicKeyToken=593777ae2d274679d 
  • Explain the differences between public, protected, private and internal. 
  • What benefit do you get from using a Primary Interop Assembly (PIA)? 
  • By what mechanism does NUnit know what methods to test? 
  • What is the difference between: catch(Exception e){throw e;} and catch(Exception e){throw;} 
  • What is the difference between typeof(foo) and myFoo.GetType()? 
  • Explain what’s happening in the first constructor: public class c{ public c(string a) : this() {;}; public c() {;} } How is this construct useful? 
  • What is this? Can this be used within a static method?

ASP.NET (UI) Developers

  • Describe how a browser-based Form POST becomes a Server-Side event like Button1_OnClick. 
  • What is a PostBack? 
  • What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState? 
  • What is the <machinekey> element and what two ASP.NET technologies is it used for? 
  • What three Session State providers are available in ASP.NET 1.1? What are the pros and cons of each? 
  • What is Web Gardening? How would using it affect a design? 
  • Given one ASP.NET application, how many application objects does it have on a single proc box? A dual? A dual with Web Gardening enabled? How would this affect a design? 
  • Are threads reused in ASP.NET between reqeusts? Does every HttpRequest get its own thread? Should you use Thread Local storage with ASP.NET? 
  • Is the [ThreadStatic] attribute useful in ASP.NET? Are there side effects? Good or bad? 
  • Give an example of how using an HttpHandler could simplify an existing design that serves Check Images from an .aspx page. 
  • What kinds of events can an HttpModule subscribe to? What influence can they have on an implementation? What can be done without recompiling the ASP.NET Application? 
  • Describe ways to present an arbitrary endpoint (URL) and route requests to that endpoint to ASP.NET. 
  • Explain how cookies work. Give an example of Cookie abuse. 
  • Explain the importance of HttpRequest.ValidateInput()? 
  • What kind of data is passed via HTTP Headers? 
  • Juxtapose the HTTP verbs GET and POST. What is HEAD? 
  • Name and describe at least a half dozen HTTP Status Codes and what they express to the requesting client. 
  • How does if-not-modified-since work? How can it be programmatically implemented with ASP.NET?
  • Explain <@OutputCache%> and the usage of VaryByParam, VaryByHeader. 
  • How does VaryByCustom work? 
  • How would one implement ASP.NET HTML output caching, caching outgoing versions of pages generated via all values of q= except where q=5 (as in http://localhost/page.aspx?q=5)?

Developers using XML

  • What is the purpose of XML Namespaces? 
  • When is the DOM appropriate for use? When is it not? Are there size limitations? 
  • What is the WS-I Basic Profile and why is it important? 
  • Write a small XML document that uses a default namespace and a qualified (prefixed) namespace. Include elements from both namespace. 
  • What is the one fundamental difference between Elements and Attributes? 
  • What is the difference between Well-Formed XML and Valid XML? 
  • How would you validate XML using .NET? 
  • Why is this almost always a bad idea? When is it a good idea? myXmlDocument.SelectNodes("//mynode"); 
  • Describe the difference between pull-style parsers (XmlReader) and eventing-readers (Sax) 
  • What is the difference between XPathDocument and XmlDocument? Describe situations where one should be used over the other. 
  • What is the difference between an XML "Fragment" and an XML "Document." 
  • What does it meant to say “the canonical” form of XML? 
  • Why is the XML InfoSet specification different from the Xml DOM? What does the InfoSet attempt to solve? 
  • Contrast DTDs versus XSDs. What are their similarities and differences? Which is preferred and why? 
  • Does System.Xml support DTDs? How? 
  • Can any XML Schema be represented as an object graph? Vice versa? 

~ Cheers
Happy hunting. 

Thursday, January 3, 2013

Phone Screen Preparation



Phone Screen Preparation

Overview:
Candidates must remember that a phone screen is the first substantial contact with the client, so approaching the interview properly is imperative. 

Being properly prepared for a phone screen takes preparation, such as having your resume in front of you, reviewing the company’s website and job description, and preparing questions for the interviewer regarding the position and company.

The most obvious (and often neglected) point to remember is this: During the interview, the company representative has only ears with which to judge you, and this is something you must overcome.  Here are some helpful tips:

q  Take the call in stride – Sound positive, friendly, and collected.  Smiling always improves the timbre of your voice and will put you in control of yourself and the situation.  Speak slowly and pronounce your words clearly.
q  Beware of over-familiarity – Always refer to the interviewer by his/her last name until instructed to do otherwise.
q  Allow the company representative to do most of the talking – Its important to keep up your end of the conversation, after all this is a sales presentation, so be sure to ask a few questions of your own that will promote you as an intelligent person.  Ask the interviewer ‘what type of challenges the department is facing’, or, ‘what immediate projects you would be involved in.’ This gives you a clear picture of how to sell yourself.  Occasionally, the interviewer will not give you the opening you need to sell yourself, so questions like these are extremely critical to understand the needs of the client.
q  Beware of yes/no answers – They give no information about your abilities.
q  Be factual in your answers – You should be brief, yet thorough.
q  Speak directly into the telephone – Keep the mouthpiece about 1 inch from your mouth and do not eat, drink, or smoke while on the phone.  In addition, phones are excellent at picking up background noise, so confine yourself to a quiet room at home, or a private conference room in your office.
q  Avoid cell phones at all cost – It would be a shame to lose an interview because you lost reception or because the interviewer couldn’t understand you.  Performing an interview on a cell phone should be a LAST resort.
q  Take notes – They will be invaluable to you when preparing for a face-to-face interview.  If, for some reason the interviewer must put you on hold, immediately jot down the topic of discussion.  Then, when the manager returns to the line, helpfully recap: “We were just discussing….”  That will be appreciated and set you apart from other candidates.
q  Admire the company’s achievements – Flattery goes a long way.  Admire the achievements and you are admiring the interviewer.  Likewise, if any common areas of interest arise, comment on them – people hire people like themselves.
q  Salary/Benefits – Unless initiated by the Interviewer, money, vacation time, or benefits should not be discussed; that comes later.
**If salary comes up this is what I suggest saying…”I’ve discussed my expectation with Assurity Staffing Group, but my main concern is finding the right fit”.

BELOW ARE POTENTIAL QUESTIONS FOR YOU TO ASK THE INTERVIEWER:

Needs Analysis- (You will use this information so you can mirror yourself to the hiring managers needs)
You should ask these questions:
q  “What is the single most important thing you are looking for in the person you hire for this position?”
q  “What does it take to be successful in this position?”           
q  Ask questions about the company/ project/ assignment.
q  What skills and experience does the ideal candidate possess?

Solve client’s needs 

q  Use the information that the manager gives you from the needs analysis and describe how your experience/ skills match what their needs are.
q  Mold yourself into what the clients needs are.
q  Communicate to the interviewer how you can meet/ exceed their needs.
q  Confirm the need and sell your values and solutions.
          

Uncover client’s concerns and overcome those concerns (Ask these questions after you have discussed your background)
q  Is there anything that I can clarify for you about my resume or background?
q  “Are there any questions or concerns you I could answer for you?
q  (If they have a concern) “I understand your concern. Let me give you a specific example of how/ why, etc.” (give explanation). Does that make you feel more comfortable?”

The Basics:
q  Always let the client finish asking his/ her questions before responding.
q  Don’t over do it with answers that run on for 15 minutes per question….
q  Turn off Cell Phones.
q  Follow up (call me after interview)
q  Don’t talk bad about former company.
q  Have a story ready about the progression of your career and the accomplishments and things you have done in the past.

Note: If you have any suggestion or really like this blog then please give some comments.

Wednesday, January 2, 2013

Telephonic Interview With Hexaware (ISO)


  1. Please brief me about your experience in .net.
  2. What is difference between Overloading and Overriding.
  3. What is the difference between Virtual and Abstract keyword.
  4. How would you rate your self in design UI from 1-10.
  5. You've mentioned Entity framework in resume. Have you every worked with NHibernate.
  6. You have mentioned Dependency injection in resume. Which framework have you used for IOC?
  7. You have also worked with NServiceBus. What is the use of it.?
  8. Let me give you a scenario. There is a Web page which has 10 questions and you wanted to save answers to server. What will be your approach. 
  9. There is class call Person. which has properties like Firstname, Last name, and PhoneNuber. I wanted a list of only firstname then what will you do.
  10. Can you overload method if they have different return type but no of parameters are same.
  11. Can you declare a method Virtual and Private?