Wednesday, July 6, 2011

Team Foundation services are not available. Fatal error while initializing web service

PROBLEM:
You get the following errors using Visual Studio Team Explorer when trying to connect TFS
  • TF31001: Team Foundation cannot retrieve the list of team projects from Team Foundation Server servername. The Team Foundation Server returned the following error: Team Foundation services are not available from the server. 
  • TF30059: Fatal error while initializing web service. 

SOLUTION:
Check if your TFS database and IIS services are OK (up and running..)

If you find this solution useful, you are welcome to press one of the ads in this page.. Thanks!



Thursday, June 30, 2011

SCRUM Wedding

PROBLEM:
You plan a wedding

SOLUTION:
You can use the following instruction guide
http://gregoryheller.com/blog/2010-12/video-scrum-wedding-planning-ignite-talk


If you find this solution useful, you are welcome to press one of the ads in this page.. Thanks!


Thursday, April 21, 2011

Design anti-patterns

PROBLEM:
What is considered to be bad code?

SOLUTION:
It’s always good to know what is considered to be good. At the same time in order to find out where you are now it’s required to know what is considered to be bad code or development style. There is a big list of anti-patterns which are related to software development. Full list of anti-patterns can be found here:


List of most interesting anti-patterns is copied and pasted below. I believe articles below can be interesting for developers of any level (juniors and seniors). If you know patterns and anti-patterns it’s easy to evaluate if you are doing something wrong or you are on the right way.

Project management anti-patterns
  • Death march: Everyone knows that the project is going to be a disaster,  except the CEO - so the truth is hidden to prevent immediate cancellation of the project - (although the CEO often knows and does it anyway to maximise profit). However, the truth remains hidden and the project is artificially kept alive until the Day Zero finally comes ("Big Bang"). Alternative definition: Employees are pressured to work late nights and weekends on a project with an unreasonable deadline. 
  • Groupthink: During groupthink, members of the group avoid promoting viewpoints outside the comfort zone of consensus thinking 
  • Smoke and mirrors: Demonstrating how unimplemented functions will appear 
  • Software bloat: Allowing successive versions of a system to demand ever more resources 
  • Waterfall model: An older method of software development that inadequately deals with unanticipated change
Analysis anti-patterns
  • Bystander apathy: When a requirement or design decision is wrong, but the people who notice this do nothing because it affects a larger number of people
Software design anti-patterns
Object-oriented design anti-patterns
  • Anemic Domain Model: The use of domain model without any business logic. The domain model's objects cannot guarantee their correctness at any moment, because their validation and mutation logic is placed somewhere outside (most likely in multiple places). 
  • BaseBean: Inheriting functionality from a utility class rather than delegating to it 
  • Call super: Requiring subclasses to call a superclass's overridden method 
  • Circle-ellipse problem: Subtyping variable-types on the basis of value-subtypes 
  • Circular dependency: Introducing unnecessary direct or indirect mutual dependencies between objects or software modules 
  • Constant interface: Using interfaces to define constants 
  • God object: Concentrating too many functions in a single part of the design (class) 
  • Object cesspool: Reusing objects whose state does not conform to the (possibly implicit) contract for re-use 
  • Object orgy: Failing to properly encapsulate objects permitting unrestricted access to their internals 
  • Poltergeists: Objects whose sole purpose is to pass information to another object 
  • Sequential coupling: A class that requires its methods to be called in a particular order 
  • Yo-yo problem: A structure (e.g., of inheritance) that is hard to understand due to excessive fragmentation
Programming anti-patterns
  • Accidental complexity: Introducing unnecessary complexity into a solution 
  • Action at a distance: Unexpected interaction between widely separated parts of a system 
  • Blind faith: Lack of checking of (a) the correctness of a bug fix or (b) the result of a subroutine 
  • Boat anchor: Retaining a part of a system that no longer has any use 
  • Busy spin: Consuming CPU while waiting for something to happen, usually by repeated checking instead of messaging 
  • Caching failure: Forgetting to reset an error flag when an error has been corrected 
  • Cargo cult programming: Using patterns and methods without understanding why 
  • Coding by exception: Adding new code to handle each special case as it is recognized 
  • Error hiding: Catching an error message before it can be shown to the user and either showing nothing or showing a meaningless message 
  • Hard code: Embedding assumptions about the environment of a system in its implementation 
  • Lava flow: Retaining undesirable (redundant or low-quality) code because removing it is too expensive or has unpredictable consequences[5][6]
  • Loop-switch sequence: Encoding a set of sequential steps using a switch within a loop statement 
  • Magic numbers: Including unexplained numbers in algorithms 
  • Magic strings: Including literal strings in code, for comparisons, as event types etc. 
  • Soft code: Storing business logic in configuration files rather than source code[7]
  • Spaghetti code: Programs whose structure is barely comprehensible, especially because of misuse of code structures
Methodological anti-patterns
If you find this solution useful, you are welcome to press one of the ads in this page.. Thanks!

Monday, January 10, 2011

6 Phases of a big project

  1. Enthusiasm,
  2. Disillusionment,
  3. Panic and hysteria,
  4. Search for the guilty,
  5. Punishment of the innocent, and
  6. Praise and honor for the nonparticipants.


If you find this solution useful, you are welcome to press one of the ads in this page.. Thanks!


Wednesday, January 5, 2011

How to use SQL Server profiler for basic profiling?

PROBLEM:
How to use SQL Server profiler for basic profiling?

SOLUTION:
To access Profiler, you must be the administrator or have permission to connect to a specific instance of SQL Server and have granted permissions to execute profiler stored procedures.
Open SQL Server profiler. If the following window not open, choose the "New Trace" button.
Use the "Standard (default)" template and go to the "Event Selection" Tab

In the event selection tab choose only

  • "RPC:Completed"
  • "SQL:BatchCompleted"

Press the run button


Now you can start to traces and analyze your queries or applications..
For more information, visit here

If you find this solution useful, you are welcome to press one of the ads in this page.. Thanks!

Sunday, November 28, 2010

Basic SQL Code Review

PROBLEM:
You want to make SQL code review to yourself or to one of your team member

SOLUTION:
Use the following list for a basic SQL code review. Remember - recommendations are good for 90% of cases. Use "Execution plan" to validate your queries

  1. Always use indexes, even for small tables
  2. Try to avoid "OR"s - may cause full table scans (UNION can replace OR)
  3. Use UNION ALL instead of UNION if possible (does not sort)
  4. Do not use SQL functions around indexed columns (will suppress the use of that index)
  5. Try to avoid sorts (or use the same order by as the index)
  6. Try to provide the WHERE clause with as many host variables that match the index
  7. Avoid JOIN's with many tables
  8. Use an OUTER JOIN instead of the NOT IN clause
  9. Using col1 > 0 is better that col1 != 0
  10. Use col1 = 40 not col1+10 = 50
  11. Use EXISTS instead of DISTINCT and IN subquery
  12. Use NOT EXISTS instead of NOT IN
  13. Use UNION instead of OR
  14. When 2 indexes exists on the same table and both rank the same (by the optimizer), the first index on the WHERE clause will be used
  15. Try to use "index only" queries if possible. Consider adding columns to existing indexes
  16. OR's are processed from left to right
  17. AND's are processed from right to left
  18. Put expensive OR's at the end part (right)
  19. Put expensive AND's at beginning part (left)
  20. Make proper use of correlated sub-queries
  21. Break up complicated SQL statements. Do not attempt to solve all situations with single statement
  22. Beware of NULLS! - IS NULL and IS NOT NULL will not use index
  23. Use >= 0 to replace NULL expression 
If you find this solution useful, you are welcome to press one of the ads in this page.. Thanks!

Tuesday, November 23, 2010

Disable all constraints, clean all database

PROBLEM:
You need to disable all constraints, clean all database

SOLUTION:

-- Disable all constraints
EXEC sp_MSForEachTable @command1="print 'NOCHECK CONSTRAINT ?'", @command2="ALTER TABLE ? NOCHECK CONSTRAINT all"

When dealing with deleting data from tables which have foreign key relationships - which is basically the case with any properly designed database - we can disable all the constraints, delete all the data and then re-enable constraints

-- Delete data in all tables
EXEC sp_MSForEachTable @command1="print 'DELETE FROM ?'", @command2="DELETE FROM ?"

-- Enable all constraints
EXEC sp_MSForEachTable @command1="print 'CHECK CONSTRAINT ?'", @command2="ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"

-- If some of the tables have identity columns we may want to reseed them
EXEC sp_MSForEachTable @command1="print 'CHECKIDENT RESEED ?'", @command2="DBCC CHECKIDENT ( '?', RESEED, 0)"

Another option is to run the following code and save the results for both drop and recreate, then execute all the drops followed by your code and then recreate the constraints using the results from the second query

SELECT 'ALTER TABLE ' + '[' + OBJECT_NAME(f.parent_object_id)+ ']'+' DROP CONSTRAINT ' + '[' + f.name + ']'
FROM .sys.foreign_keys AS f
INNER JOIN .sys.foreign_key_columns AS fc
ON f.OBJECT_ID = fc.constraint_object_id

SELECT 'ALTER TABLE [' + OBJECT_NAME(f.parent_object_id)+ ']' +' ADD CONSTRAINT ' + '[' + f.name +']'+ ' FOREIGN KEY'+'('+COL_NAME(fc.parent_object_id,fc.parent_column_id)+')'+'REFERENCES ['+OBJECT_NAME (f.referenced_object_id)+']('+COL_NAME(fc.referenced_object_id, fc.referenced_column_id)+')' as Scripts
FROM .sys.foreign_keys AS f
INNER JOIN .sys.foreign_key_columns AS fc
ON f.OBJECT_ID = fc.constraint_object_id

To handle table constraints:

-- Disable all table constraints
ALTER TABLE MyTable NOCHECK CONSTRAINT ALL

-- Enable all table constraints
ALTER TABLE MyTable CHECK CONSTRAINT ALL

To handle single constraint:

-- Disable single constraint
ALTER TABLE MyTable NOCHECK CONSTRAINT MyConstraint

-- Enable single constraint
ALTER TABLE MyTable CHECK CONSTRAINT MyConstraint


If you find this solution useful, you are welcome to press one of the ads in this page.. Thanks!