Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Sunday, February 13, 2011

Understanding ASP NET ORM 101

LINQ stands for language integrated query. It allows you to use "SQL style" query language directly within C# to extract information from data sources.

  • That data source could be a SQL server database - this is Linq to SQL
  • That data source could be an data context of entity framework objects - Linq to entities.
  • That data source could be ADO.net data sets - Linq to Dataset.

That data source could also be an XML file - Linq to XML.
Or even just a Collection class of plain objects - Linq to Objects.

LINQ describes the querying technology, the rest of the name describes the source of the data being queried.

For a bit of extra background:

Datasets are ADO.net objects where data is loaded from a database into a .net Dataset and Linq can be used to query that data after it's loaded.

With Linq to SQL you define .net classes that map to the database and Linq-to-SQL takes care of loading the data from the SQL server database

And finally the Entity framework is a system where you can define a database and object mapping in XML, and can then use Linq to query the data that is loaded via this mapping.

And also

  • all of them are LINQ - Language Integrated Query - so they all share a lot of commonality. All these "dialects" basically allow you to do a query-style select of data, from various sources.

  • Linq-to-SQL is Microsoft's first attempt at an ORM - Object-Relational Mapper. It supports SQL Server only. It's a mapping technology to map SQL Server database tables to .NET objects.

  • Linq-to-Entities is the same idea, but using Entity Framework in the background, as the ORM - again from Microsoft, but supporting multiple database backends

  • Linq-to-DataSets is LINQ, but using is against the "old-style" ADO.NET 2.0 DataSets - in the times before ORM's from Microsoft, all you could do with ADO.NET was returning DataSets, DataTables etc., and Linq-to-DataSets queries those data stores for data. So in this case, you'd return a DataTable or DataSets (System.Data namespace) from a database backend, and then query those using the LINQ syntax

Sunday, December 19, 2010

me, myself and C

Most beginning programmer get lost with the C programming language specifically the heart and soul which is POINTERS!

Why we need C/C++ POINTERS

1.Data management on the free store
2.Accessing class member data and functions
3.Passing variables by reference to functions

Example:

char m[] = {1,2,3,4,5}
char *p;
p = &m[3];

Pointers on C-POINTERS

1. Variables in C are memory locations
2. If you are going to change the variable you pass the variable by using pointers otherwise pass it by value e.g

changing the variable "s" pass by pointers

char *str( int i, char *s)
{
while(i) {
s++;
i--;
}
return s;
}


void none(int i)
{
i = i + 1;
return 1;
}

3.) C++ Friend function/classes are used for accessing methods + variables between classes of different type its a communication tool

4.) static void () the function is only visible in the file in which it is defined





Saturday, December 11, 2010

Love/Hate Objective C

I recently realized that the learning curve of Java on Android compare to Objective C on iOS is a lot better. The documentations are robust anyway let's just cut the chase this post is about the beauty of Objective C .

OBJECTIVE C for starter

1.) NSLog is a function that
-- Can take one or more parameters. The first parameter is generally the string that is to be printed to the console. The @ symbol in front of the string tells the compiler that this is an Objective-C type string and not a C++ string. The @ symbol is typically used in front of all your strings for iPhone apps. If you do not use the @ symbol, you will probably get a compiler error.
2.) % is called the modulus operator.
This operator returns the remainder of its two operands.

3.) @ tells the O/S that is an objective C file

Classes Terminologies

4.) Pointers are like business card you don't see the real person yet you have the idea that you can reach him anytime.

5.) Two types of class methods
a.) class-method this are static function that uses the + sign (synonymous to public static function myMethod() in php )
+ used for messages that can be used before the object is created. (pseudo static )
b.) instance-method this are the default function of a class denoted by the - sign ( synonymous to private function myMethod() in php)
-(float) Power:(float)width:(float)height; in C/C++ you would write it like this float Power( float width , float height)

- (id)initWithName:(NSString *)newName atFrequency:(double)newFreq {
public function WithNameatFreq(new Name , new Freq)
char getName(char name)
{
}
@interface classname : superclassname {
// instance variables
}
+classMethod1;
+(return_type)classMethod2;
+(return_type)classMethod3:(param1_type)param1_varName;
-(return_type)instanceMethod1:(param1_type)param1_varName :(param2_type)param2_varName;
-(return_type)instanceMethod2WithParameter:(param1_type)param1_varName andOtherParameter:(param2_type)param2_varName;
@end

Note:
Class members declared PUBLIC can be accessed everywhere.
Members declared PROTECTED can be accessed only within the class itself and by inherited and parent classes.
Members declared as PRIVATE may only be accessed by the class that defines the member.
A private method is a method which is not inherited by subclasses. A private variable cannot be used outside the class
A public method is a method which can be called by any object of the class
A protected method can be called by any subclass within its class, but not by unreleated classes.

How to create a new Objective C class project

1.Choose MACOSX application
2.Select Command Line Tool ,ensure that Foundation is chosen for the type
3.If you want to add new objects Add New File
then choose Objective-C class from the MACOSX group make sure the Subclass
of dropdown is set to NSObject
4.How to initialize a class

myObject = [[MyClass alloc] init];
--
HelloWorld* myObject = [[HelloWorld alloc] init];
[myObject printGreeting];
[myObject release]; return 0;

self = meaning successful
nil = meaning failure

Happy coding! :)

nostalgia

Back in college my first assembly language machine problem is reading character input. I found the following old snippets from the nostalgia of my college days.

;======================
.model small
.stack 64
.data
pass db 'wade','$'
ass db '*','$'
input db 'Enter Password: ','$'
invalid db 'Sorry, Invalid Password',13,10,'$'
valid db 'Access Granted',13,10,'$'

.code
main proc near
begin:

add bx,1
mov ah,06
mov al,00
mov bh,07
mov cx,00
mov dx,184fh
int 10h
mov ax,@data
mov ds,ax
mov cx,4
lea SI,pass
mov ah,02
mov bh,00
mov dh,09
mov dl,30
int 10h
mov ah,09
mov dx,offset input
int 21h
compare:
mov dl,[SI]
mov ah,07
int 21h
cmp al,dl
JE right
jmp wrong
right: inc SI
mov ah,09
mov dx,offset ass
int 21h

loop compare
mov ah,07
int 21h
mov ah,02
mov bh,00
mov dh,13
mov dl,34
int 10h
mov ah,09
mov dx,offset valid
int 21h
mov ah,07
int 10h
mov ah,4ch
int 21h
start: JE begin
wrong: inc SI
mov ah,09
mov dx,offset ass
int 21h
mov dl,[SI]
mov ah,07
int 21h
cmp al,dl
loop wrong
mov ah,02
mov bh,00
mov dh,13
mov dl,29
int 10h

mov ah,09
mov dx,offset invalid
int 21h
mov ah,07
int 21h
cmp bx,1
JE start
cmp bx,2
JE start
jmp exit
exit:
int 18h
main endp
End main

That is all folks.

Saturday, November 27, 2010

For Your Dreams To Become Real: Try Unreal

Unreal. The engine that powers most of your favorite games. Epic Games, the creators of Unreal Engine, releases the latest beta version of Unreal Development Kit (UDK). Here's a sample video of what it can do.



UDK is free of charge. Isn't that nice?

Since many game developers use it, why not give it a try? Download it now at udk.com.

Sources:
UDK.com
Joystiq.com

Saturday, November 20, 2010

Programming

Programming

with 5 comments

Ten Commandments for Stress Free Programming:
1) Thou shalt not worry about bugs – bugs in your software are actually special features.
2) Thou shalt not fix abort conditions – your user has a better chance of winning state lottery than getting the same abort again.
3) Thou shalt not handle errors – error handing was meant for error prone people, neither you or your users are error prone.
4) Thou shalt not restrict users – don’t do any editing, let the user input anything, anywhere, anytime. That is being very user friendly.
5) Thou shalt not optimize – your users are very thankful to get the information, they don’t worry about speed and efficiency.
6) Thou shalt not provide help – if your users can not figure out themselves how to use your software than they are too dumb to deserve the benefits of your software anyway.
7) Thou shalt not document – documentation only comes in handy for making future modifications. You made the software perfect the first time, it will never need modifications. 8) Thou shalt not hurry – only the cute and the mighty should get the program by deadline.
9) Thou shalt not revise – your interpretation of specs was right, you know the users’ requirements better than them.
10) Thou shalt not share – if other programmers needed some of your code, they should have written it themselves.

Software Development Cycle:
1) Programmer produces code he believes is bug-free.
2) Product is tested, 20 bugs are found.
3) Programmer fixes 10 of the bugs and explains to the testing department that the other 10 aren’t really bugs.
4) Testing department finds that five of the fixes didn’t work and discovers 15 new bugs.
5) Repeat three times steps 3 and 4.
6) Due to marketing pressure and an extremely premature product announcement based on overly-optimistic programming schedule, the product is released.
7) Users find 137 new bugs. 8) Original programmer, having cashed his royalty check, is nowhere to be found. Newly-assembled programming team fixes almost all of the 137 bugs, but introduce 456 new ones.
Original programmer sends underpaid testing department a postcard from Fiji. Entire testing department quits.
9) Company is bought in a hostile takeover by competitor using profits from their latest release, which had 783 bugs.
10) New CEO is brought in by board of directors. He hires a programmer to redo program from scratch.
11) Programmer produces code he believes is bug-free…

This post is an excerpt :D