vineri, 23 octombrie 2009

[Agile] [Patterns] Automated Developer Tests

See also.
Patterns are "discovered" and not "created."

-> A set of tests that are written and maintained by developers to reduce the cost of finding and fixing bugs - thereby improving code quality—and to enable the change of the design as requirements are addressed incrementally. Disciplined writing of tests encourages loosely coupled designs.
____________
- checking errors
- flexibility and program lifetime are improved - enable Refactoring.
- write your tests first and practiced Test-First Development
____________________

Context:

- needs to significantly improve its quality (reduce bug count)
- you decide to adopt Iterations and Simple Design
- build code using a distributed team - lack of communication
- practicing Collective Code Ownership

Forces:

- QA person and a developer must both find the bug and communicate via a tool to document the work being done
- bugs go back and forth between QA and development
- QA time to found, discovered, and fixed is greater then developer time to .... .
- Fixing one bug frequently causes another bug.
- Complex parts of the system tend to have more bugs than others
- Systems are designed to be general so that when requirements change the system can accommodate the changes.

Therefor:

- fixing bugs by finding them earlier: have developers test their code more rigorously
- automated testing
- test before checking
- document the change
- add a new test for a bug

- developers are more confident and courageous and will make design changes when needed relying on the tests that have been written to catch their mistakes.
- Read what others are writing

Adoption:
1. Commit as a team to the discipline of writing tests.
- Tests are just as important as production code
- Future complete it is only if tests are completed.
- Agree to be patient.
2. Find a tool that is easy to use. (examples: NUni, TestComplete)
- Use automatic testing tools as auxiliary testing and not the primary form of testing.
3. Treat your test code as you would your production code.
4. Try to get help:
- Bring in an experienced consultant
- Use other persons from your company that succeeded
- Read books
- Focused on TDD, Agile Development
5. Adopt Collective Code Ownership
6. Consider adopting Pair Programming
7. Start writing tests with the current Iteration
8. Within a few Iterations your team will come up against the problem of setup data
- Create a framework: Pull out the common setup code into common classes.
- Use Mocks and Stubs
9. Agree as a team on an approach and follow it.
10. Use Mock objects and Stubs to test classes that communicate with external systems.

But:
- It needs everyone on the team to be on board.
- The fact that tests are written says absolutely nothing about the quality of the production code. Adopt Pair Programming or performing regular code reviews on tests.
- Tests sometimes end up as second class citizens: we break all the rules of good design: Refactor it when the design is no longer adequate.
- Writing tests—especially for existing systems that have been written without testing in mind—is very hard.
- All tests should be running and passing all the time—no excuses.
- Code coverage becomes an overly important metric.

joi, 22 octombrie 2009

[Agile] The Technical Cluster

The Technical Cluster


-> main idea: deliver value for customer

Business value:
-> Reducing time to market of developing software
-> Increase value to market
- the most useful software to the customer. Does it help them to do their job better?
-> Increase quality to market
- deal with concepts such as defects, usability, and scalability.
- ability to respond to changes they request
-> Increase visibility
- customer’s ability to see the true state of the project as it progresses. -> manage risks and expectations
-> Reduce cost: Faster, better, cheaper.
- cost associated: manhours to build the system, maintenance of the system over time, and hardware as well as software platform costs.
The 80/20 rule says that roughly 20% of the product is used 80% of the time.
-> Increase product lifetime
- directly affects the product’s Return on Investment (ROI).
____________________________________
Strategy:
- Rank Business Values (from customer point of view)
- Compare to your values
- Determine key values
- Focus on issues that increase business value
- Implement a practice to improve a particular business value
- Periodic reading to verify that the practice is working.

___________________________________
"Smell":
- An indicator of something that has gone wrong.
- Deciding what issues need to be addressed and in what order.
- There are Business smells (visible to customers) and Process Smells (inner)

Business Smells
- Quality Delivered to Customer is Unacceptable
- Delivering New Features to Customer Takes Too Long.
-> Issues:
• Features rely on expert resources that are bottlenecked.
• The testing cycle takes significant time.
• Features required were unforeseen and are hard to add given the existing architecture.
- Features Are Not Used By Customer
-> Customers didn't know what they really needed at the requirement phase
-> Requirements from marketing are just a forecast. The forecast isn't always on-track.
-> Some features are used much less frequently than we anticipated.
-> Developers have been known to add features that they were sure would be useful but were not.
-> Requirements changed.
- Software Is Not Useful To Customer
- Software Is Too Expensive To Build

Process Smells
- Us vs. Them at any level indicates that there are communication barriers and that business value is not on the radar.

- Customer Asks for Everything Including the Kitchen Sink
- Direct and Regular Customer Input is Unrealistic.
-> Our marketing team is our pseudocustomer. They are separate and have their own work to do.
-> features are not used by customer; software is not useful to custome; and software is a burden to use.
- Management is Surprised—Lack of Visibility
-
Bottlenecked Resources
-> There is significant research showing that multi-tasking is significantly less efficient than single-tasking.
- Projects miss their deadlines multiple times.
- Hundreds (Possibly Thousands) of Bugs in Bug-Tracker
- Integration is Infrequent
->The lack of Integration results in a significant amount of untested code.
-> A significant number of errors, miscommunications, and misconceptions remain undiscovered until the end of the release cycle.
_____________________________________

- Prioritized list of business values and a prioritized list of smells that need fixing.
- Practices and Clusters that Improve Business Value



















- Practices and Clusters that Alleviate Smells



















- Be Business-Value Focused
-> If you do not have access to the customer then you should do your best to get that access
- Be Goal-Oriented
-> Marketing doesn’t care if you are adopting Test First Development or not. They care that the product has fewer defects.
- Adopt Iteratively -> Adopt in small steps
- Be Agile About Your Adoption - Use the feedback from those retrospectives to modify your
development process
__________________________________
Test-Driven Adoption Strategies

1. Start with an evaluation of the status quo
2. Set goals that you want to reach.
3. Pull the first practice or cluster off the list you created.
4. Read the pattern that is related to that cluster or practice.
5. Read the pattern thoroughly.
6. Periodically evaluate
7. Go back to 1.

Next here.

[Fun] Mic dictionar de resurse umane

“Junior” – scriem asta in titlu ca sa fie clar cat platim, vin acuma si cerintele
“Companie in plina dezvoltare” – ti-o bagam pe aia ca te platim doar la inceput prost pana ne ridicam
“Conditii financiare la nivelul pietei” – e criza la toti nu numai la noi
“Laptop de serviciu” – vei avea de lucru si acasa
“Persoana cu capacitate de a lucra independent” - cum ziceam, vei avea de lucru si acasa
“Abilitatea de a invata lucruri noi” – cum sa tragi de salariu doua luni, cum sa faci economie la mancare, etc
“Pachet salarial motivant” - te motiveaza sa cauti in permanenta si altceva
“Echipa tanara” – nu ne permitem decat studenti
“Cu dorinta de autodepasire zilnica” – azi 8 ore la munca, maine 8.5, poimaine 9 etc
“Telefon serviciu” - trebuie sa avem o metoda de a da de tine si sambata
“Nascut in zodia Fecioara” – ‘TF ?
“Pasionat de domeniul IT” – sa aiba abilitatea de a instala saptamanal windowsul secretarei si la doua zile sa vada de ce nu merge imprimanta
“Creativitate” – O sa mai faci si munca altora
“Conditii de lucru la standarde occidentale” – Scaun cu spatar
“Acces la cel mai performant software” – P2P
“Mediu tanar si dinamic” – schimbam studentii in fiecare an
“Program flexibil” – Se poate intinde oricat
“Salarizare pe masura realizarilor profesionale” – noi ne facem ca platim, tu te faci ca muncesti
“Simtul umorului” – mai ales in ziua de salariu
“Mediu competitiv” – colegi care te sapa
“Salariu motivant” – Mai mult pentru nagajator (asta din urma e o specie de salariu foarte des intalnita, mai toti il ofera)

miercuri, 21 octombrie 2009

[Bianca] In octombrie

Am sapte luni. Mergem spre opt.
Tata s-a gandit sa-mi tina jurnal. Dupa un model dintr-un ziar.

Ne-au iesit inca doi dintisori. Cei din fata, sus. Cate unul pe rand. Ca n-oi putea face scandal doar o data. Avem patru acum.

Am si racit. Imi curge nasul, mi se infunda, respir pe gura. Fac un scandal nemaipomenit cand ma curata tata in nas cu batista bebelusului (aspiratorul asta face cam mult zgomot). Si nu-mi plac obiectele bagate in nas. Daca ma mai si da cu apa de mare in nas, scandalul este dublu.
Mai am putin si o bag in boale pe mama. Dar ma fac eu bine.

Ne trezim o data pe noapte. In general. Daca laptele nu e gata pe loc, facem scandal monstru. Vecinii cred ca s-au obisnuit deja. Dupa masa de noapte, somnic. Pana pe la 7 juma, uneori 8 juma. Dupa care care incepe concertul. Sunt vorbareata si jucausa. Si tip. La asta ma pricep destul de bine.

Dorm singura. Doar daca nu sunt racita.

De obicei, cand ma trezesc, vine tati sa ma ia. Ne mutam in sufragerie. Sa mai poata si mama dormi putin.

Mancam laptelul de dimineata. In mai multe reprize. Nu tot de o data.
Pe la 9-10 imi e somn. Again. Dar nu pentru mult timp. O juma de ora de somn si sunt in picioare. Daca nu primesc atentie fac scandal.

Daca e frumos afara, eu si mama facem turul de cartier.

La 12 masa de pranz. Supita cu carne sau cu galbenus de ou. Gatita de ma-ma-ma. Mananc din ce in ce mai bine.
La 15 fructe. Cu biscuiti de ceva vreme sau cu cereale.
La 17 iaurtel. Si imi place. Il mananc tot si uneori trec si la al doilea.

Mami e tot timpul cu mine. Ne jucam , mancam, ne schimbam de cacaciosi. Rar, pauze. Atunci cand dorm. Poate reuseste si ea sa citeasca emailul si sa se uite la TV. Asta doar in cazul in care nu are de spalat hainute sau scaunelul de masa murdarit de mine cu spor. Sau sa mai aseze cate ceva prin casa.

Poate iesim afara si seara. Imi place in leagan.
Dupa plimbarea de seara vin acasa. Daca mai mananc, bine. Daca nu, somnic. Sau daca nu e somnic e scandal.

Pe la 8, 8 si ceva, seara, hop si tata.
Incepe din nou joaca. Chiar daca tati e obosit. Nu dureaza mult ca mergem la baita.

In baita totul e frumos. Ratuste Batem cu manutele in apa. Mai dam si apa pe afara. Ne place. Mai putin partea cu spalatul pe la urechiute si pe la nasuc.

Dupa baita, imbracatul. Aici se schimba foaia. Plang, ca din gura de sarpe. Pana nu vad laptelul, cu cereale, nu ma opresc.

Dupa laptel, pic ca un soldat. Nani. Cu tigrusorul, bineinteles. Este preferatul meu. Il musc de coada, de labute. Nu se supara.

vineri, 16 octombrie 2009

[C#][Regex] Regular expressions

Timestamp (HHHH(0-9999):MM(00-59):SS(00-59).mmm(000-999)):
"(\d{1,4}):([0-5]\d):([0-5]\d)\.\d{3}"
Timestamp (DDDD
(0-9999):HH(00-23):MM(00-59):SS(00-59).mmm(000-999)):
"(\d{1,4}):([0-1]\d|2[0-3]):([0-5]\d):([0-5]\d)\.\d{3}"
IPv4: "(((([0-9])|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5]))\.){3}(([0-9])|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5])))"
Ipv6: "((((0){0,1}|([1-9a-fA-F]([0-9a-fA-F]){0,3})):){2,7}((0){0 ,1}|([1-9a-fA-F]([0-9a-fA-F]){0,3})))"
IPv4 mask: "^(([0-9])|([1-2]{1}[0-9]{1})|([3]{1}[0-2]{1}))$"
Ipv6 mask: "^(([0-9])|([1-9]{1}[0-9]{1})|(([1])([0-1])([0-9]))|(([1])([2])([0-8])))$"
Hex: "0x[0-9A-Fa-f]+"

[C#][Regex] TimeStamp

I need a regex expression in order to validate a time stamp in the following template:
DDDD:HH:MM:SS.mmm
It contains:
- days (max 9999 -> 0 - 9999)
- hours (00-23)
- minutes (00-60)
- seconds (00-60)
- milliseconds (000-999)

To validate only digits it can be used:
@"\d{1,4}:\d{2}:\d{2}\.\d{3}"

To validate the hours/minutes/seconds it can be used:
(DDDD(0-9999):HH(00-23):MM(00-59):SS(00-59).mmm(000-999))
@"(\d{1,4}):([0-1]\d|2[0-3]):([0-5]\d):([0-5]\d)\.\d{3}"

to validate a timestamp in the following format it can be used the following regular expression: (HHHH(0-9999):MM(00-59):SS(00-59).mmm(000-999)):
@"(\d{1,4}):([0-5]\d):([0-5]\d)\.\d{3}"

[DessignPatterns][C#] Hashfile/Indexing Technique

HashFile is a technique to insert/delete/find key value pairs in a file in the hard disk. It uses fixed length records to store data and index. There are two files “name.dat” and “name.idx” corresponding to a "name". "name" is the identification for key/value pairs, and is given at the time of initialization.

"name.dat”
This is the data file. The Data file stores fixed length records of key/value pairs. Name of key/value pair, length of key and value should be specified at the time of initialization. Maximum size of the data file could stretch up to 2^32 bytes, which is the maximum value of unsigned integer (uint32).

“name.idx”
This is the index file. It stores fixed length records of record pointer and index pointer. Record pointer and index pointer are unsigned integers.

Indexing Technique

It uses Index Block (IB) of 91 x 2 Matrix to store record and index pointers. When Hashfile is initialized for the first time, an empty IB will be created and every element will be filled with max value of data type uint. Why 91 rows? 91 is the number of characters in the ASCII range 32-122. Each row in the IB represents an ASCII character. Columns of the IB are record pointer and index pointer. Data types of columns are unsigned integers. Record pointer represents the starting byte index number of a data record with respect to the origin, similarly index pointer represents starting byte index number of an Index record with respect to the origin.
Pseudo code for InsertKey method is given below:
  1. Take a byte from the new key
  2. If byte is within range 32-122, then jump to the matching index record within an IB that corresponds to distance from the left most byte, otherwise return error
  3. Read record pointer and index pointer
  4. If index pointer is equal to maximum value of data type uint, then, save record pointer and index pointer, save key and value in the data record and return record pointer
  5. Otherwise read data record for the record pointer
  6. Compare new key and existing key
  7. If new key matches existing key in the data record, then go to step 10
  8. If new key is greater than existing key, then go to step 11
  9. Otherwise step 13
  10. If the status of the data record is deleted then, save new value, change deleted flag to false, return record pointer, otherwise return error
  11. If index pointer points to next IB, take next byte and jump to step 2
  12. Otherwise create new IB, save record pointer and index pointer in the new IB, assign start index pointer of new IB to the old IB, save key and value in the data record, return record pointer
  13. If index pointer points to next IB, assign new record pointer to the index record, swap new and existing keys jump to step 2
  14. Otherwise assign new record pointer to the index record, create new IB, assign existing record pointer, new index pointer to new IB, assign start index pointer of new IB to the old IB, save key and value in the data record, return record pointer
See, also, http://www.codeproject.com/KB/recipes/HashFile.aspx

[SQL] Table-value parameter Sample

CREATE TYPE TVP_STATISTICS AS TABLE(
STAT_ID Int,
STAT_NAME VARCHAR(50)
)
GO

CREATE PROCEDURE PROC_USE_TVP(
@ID Int,
@TABLE_PARAM AS TVP_STATISTICS READONLY -- MUST BE READONLY AND NOT for OUTPUT
)

AS
BEGIN
SET NOCOUNT ON;
SET XACT_ABORT ON

BEGIN TRAN

SELECT V.ID, V.NAME, TP.STAT_ID, TP.STAT_NAME
FROM VIEW V
INNER JOIN VIEW_STATISTICS VST ON V.ID = VST.VIEW_ID
INNER JOIN @TABLE_PARAM TP ON TP.ID = VST.ID

COMMIT
RETURN

END
GO

miercuri, 14 octombrie 2009

[C#] questions

1. What print to console the following line Console.WriteLine(
1<<2-1
); ?
a. 2
b. 7
c. 4
d. 3

2. What is it in caption variable?
Hashtable m_idsToColumnsCaptions;
long valueId = 0l;
m_idsToColumnsCaptions = new Hashtable();
m_idsToColumnsCaptions.Add(valueId, "Hello");
string caption = m_idsToColumnsCaptions[(int)valueId] as string;

a. "Hello"
b. Throw an exception
c. null
d. System.String

3. What is the result of running the following line of code?

Console.WriteLine((string)null);

a. This line of code has a compile time error.
b. It throws a NullReferenceException
c. Write null to the console
d. an empty line is written to console

4. Giving the following sequence of code:

public class A
{
public A(string i_masagge) {}
}

internal class B : A
{
internal B() {}
}
what will happen?

a. it is compiling perfectly.
b. there is an access problem.
c. a compile error is thrown
d. a run time error is thrown.

Answers:
1. a.
2. c.
3. d.
4. c.

[DesignPattern] About

A bad design:
- Rigidity
- Fragility
- Immobility

Principles:
- Open Close Principle
      - open for extensions
      - close for modifications
- Dependency Inversion Principle
       - high level modules should not depend on low level modules
       - abstract should not depend on details
- Interface Segregation Principle
       - interfaces should be minimal and complete
- Liskov's Substitution Principle
       - derives types must be completely substitutable for their base type

Classification:
- purpose
  • creational
  • structural (Structural patterns are concerned with how classes and objects are composed to form larger structures.)
  • behavioral
- scope
  • class
  • object


marți, 13 octombrie 2009

[DesignPattern] Adapter

-> Somehow we could encounter a situation that we have a class completely developed, and we are not allowed to create/modify that class, but we still want to communicate (consume) with it. In that case, we need to have an adapter to enable that class
-> Very useful for the system integration when some other components have to be adapted by the existing system.

Adapter Design Pattern Structure

Adapter1.JPG

Classes:
- an interface for Target (class to which the non-adapted class should be adapted) : ITarget
- a class NonAdapted (does not implement ITarget)
- a class Adapter (has a field of type NonAdapted and implement ITarget using fuctionality from NonAdapter class)
- an interface ICommunicator - interface that contracts other classes to be a Communicator and gain the ability to communicate to an ITarget object

public interface ICommunicator
{
ITarget ObjectToTarget { get; set; }
void StartCommunication();
}

- a class Communicator : ICommunicator

[DesignPattern] MVP

Model-View-Presenter is a design pattern for separating the concerns of display and data.

  • Model - The observable data model that is the subject of the user-story.
  • Presenter - A construct that takes data from the model and exposes it to views.
  • View - Shows the interaction and display surface of the application.
-> acts as an external mediator


Model-View-Controller
Model-View- Presenter

ModelViewController.png ModelViewPresenter.png

Application domain logic
View
Application domain logic

Receives model elements from controller. Displays and interacts with element.
Controller
Receives data from presenter, notifies presenter of interactions.

Supervises view/model, performs actions in response to events/changes. Delegates events to model. Re-maps model outgoing events into state changes.

-> MVC: a view would receive an update and manipulate the model accordingly after being configured by its controller.


ModelViewPresenter_AbstractPresenterView.png
MVP - abstract

[Info] Articole interesante

HR:
http://www.noop.nl/2009/01/100-interview-questions-for-software-developers.html

Project Management:
http://www.smashingmagazine.com/2008/11/13/15-useful-project-management-tools/

Presentation:
http://www.cio.com/article/print/466163

Software:
http://www.codeproject.com/KB/dialog/DynamicResizeControlsForm.aspx
http://www.codeproject.com/KB/cs/GpsMapping.aspx
http://www.pluralsight.com/main/partnerprograms/redgate.aspx?sc=2

Other columns:
http://www.infoworld.com/t/user-problems/what-tech-vendors-really-think-customer-cow-950?source=IFWNLE_nlt_daily_2009-10-29

joi, 8 octombrie 2009

[WCF] Different Shapes of Channels

Different Shapes of Channels

public interface IOutputChannel : IChannel {
void Send(Message message);
}
public interface IInputChannel : IChannel {
Message Receive();
}
public interface IDuplexChannel : IInputChannel, IOutputChannel { }
public interface IRequestChannel : IChannel {
Message Request(Message message);
}
public interface IReplyChannel : IChannel {
IRequestContext ReceiveRequest();
}
public interface IRequestContext : IDisposable {
Message RequestMessage { get; }
void Reply(Message message);
}


[WCF] [ServiceContract]/[OperationContract]

To influence the service contract, the [ServiceContract] attribute has several parameters that have their own functions:
CallbackContract: Gets or sets the type of callback contract. This is useful when using the duplex messaging exchange pattern.
ConfigurationName: Defines the name as used in the configuration file to store the related configuration settings.
Name: Gets or sets the name for the element in WSDL. The default value is the name of the .NET interface.
Namespace: Gets or sets the namespace for the element in WSDL. The default value is the namespace of the .NET interface.
HasProtectionLevel: Defines a (read-only) value that indicates the protection level of the service. At the operation level, it is possible to define that the messages of the operation must be encrypted, signed, or both.
ProtectionLevel: Defines the protection level that the binding must support.
SessionMode: Gets or sets a value that defines whether the contract requires the WCF binding associated with the contract to use channel sessions. SessionMode is an enumeration with possible values of allowed, notallowed, and required. The default value is allowed.
_______

The same is true for the [OperationContract] attribute. Several parameters are available
to you:
Name: Specifies the name of the operation. The default is the name of the operation.
Action: Defines the (WS-Addressing) action of the request message.
AsyncPattern: Indicates that the operation is implemented asynchronously by using a egin/End method pair.
IsInitiating: Defines a value that indicates whether the method implements an operation that can initiate a session on the server.
IsOneWay: Defines a value that indicates whether an operation returns a reply message. IsTerminating: Defines a value that indicates whether the operation causes the server to close the session after the reply message is sent.
ProtectionLevel: Defines a value that indicates the protection level of the operation. You can define that the messages of the operation must be encrypted, signed, or both.
ReplyAction: Defines the value of the SOAP action for the reply message of the operation.

_____________
[DataContract]
-> you can also annotate your custom types with the [Serializable]
-> you have to specifically annotate each property with the [DataMember] attribute (even is public or private one).

[DataContract] attribute has several parameters that have their own functions:
Name: Defines the name for the data contract, which will also be the name in the XML schema (XSD, WSDL). The default value is the name you defined in .NET.
Namespace: Defines the namespace for the data contract. Use this property to specify a particular namespace if your type must return data that complies with a specific data contract or XML schema.

Several parameters for the [DataMember] attribute:
Name: Defines the name for the data contract, which will also be the name in an XML schema (XSD, WSDL). The default value is the name you defined in .NET.
Namespace: Defines the namespace for the data contract. Use this property to specify a particular namespace if your type must return data that complies with a specific data contract or XML schema.
IsRequired: Gets or sets a value that instructs the serialization engine that the member must be present.
Order: Gets or sets the order of serialization and deserialization of a member. This can be important if clients rely on the order of the fields.
EmitDefaultValue: Gets or sets a value that specifies whether to generate a default value of null or 0 for a field or property being serialized.

marți, 6 octombrie 2009

[WCF] Summaries III

First Part Here
Second Part Here












_________________________________________
Addresses in WCF

- Addresses in WCF are URLs that define the protocol used, the machine where the service is running, and the path to the service
- So, the format of a service address is as follows:
scheme://[:port]/path1/path2

Address Section Description
Transport scheme This defines the transport protocol (or scheme).
Machinename This specifies the fully qualified domain name of the machine.
Port The port is an optional field and is specified as :port. Port 80 is the default for HTTP addresses.
Path The path is the specific path to the service. You can define paths as names of directories separated by a forward slash. For example, /Stock/GetQuote is the path in the following address: http://localhost:8080/Stock/GetQuote.

In aWCF configuration, you can set the HTTP address as follows:
<endpoint
address="http://localhost:8080/QuickReturns/Exchange"
bindingsSectionName="BasicHttpBinding"
contract="IExchange" />

TCP transport uses the net.tcp: scheme.
Microsoft Message Queue (MSMQ) transport use the net.msmq scheme.
-> Port numbers don’t have any meaning in the MSMQ address.
-> net.msmq://localhost/private$/QuickReturnSettleTrade
Named Pipes : net.pipe://localhost/QuickReturns/Exchange

WCF supports base addresses, which enables you to host multiple endpoints under the same base address and which shortcuts the duplication of the scheme, host, port, and root path in your configuration.

name="BasicHttpBinding"
address="Exchange"
bindingsSectionName="BasicHttpBinding"
contract="IExchange" />

___________________________________________

What Are Bindings?
-> defines how you can communicate with the service?

The binding controls the following:
• The transport (HTTP, MSMQ, Named Pipes, TCP)
• The channels (one-way, duplex, request-reply)
• The encoding (XML, binary, MTOM…)
• The supported WS-* protocols (WS-Security, WS-Federation, WS-Reliability, WS-Transactions)

->you can have multiple endpoints defined for a service so that your service
supports any combination of these bindings
___________________________________
What Are Contracts?
-> One of the core principles of service orientation is explicit boundaries
-> The essence of contracts in service orientation is that you agree on what you expose to the outside
-> A contract is a declaration of exposed behavior
-> WCF service contracts can express three message exchange patterns that can be used in your:

  • Request-Reply (In WCF, request-reply is the default pattern)
  • One-Way (“fire-and-forget” style of messaging)
  • Duplex (a peer-to-peer connection, with both ends simultaneously acting as both a sender and a receiver)
The service contract is commonly referred to as the service interface or the exposed behavior of the service.

[ServiceContract] - service contracts
[OperationContract] - operations
[DataContract]->Data contracts control the mapping between SOAP messages and .NET objects.

See parameters here
_____
[MessageContract] attribute allows you to map fields into either the SOAP body or the SOAP headers by means of the [MessageBody] and [MessageHeader] attributes.
_________________________________

WCF is a layered framework similar to the Open Systems Interactive (OSI) model

The messaging layer is the layer where the actual communication on the wire is happening.
The address expresses where the message should go, and the binding is the model you use to manipulate the message.
The binding is the mechanism to control the channel stack.
The channels are responsible for transferring a message.

__________________________________
Different Shapes of Channels

public interface IOutputChannel : IChannel {
void Send(Message message);
}
public interface IInputChannel : IChannel {
Message Receive();
}
public interface IDuplexChannel : IInputChannel, IOutputChannel { }
public interface IRequestChannel : IChannel {
Message Request(Message message);
}
public interface IReplyChannel : IChannel {
IRequestContext ReceiveRequest();
}
public interface IRequestContext : IDisposable {
Message RequestMessage { get; }
void Reply(Message message);
}

_____________
Channels come in three flavors:
• Transports
• Encoders
• Protocols



ASMX

ASMX
->
Web services are based on the notion of a service and transfer the data in messages.
-> a class : System.Web.Services.WebService
-->
contains the method to be exposed with the [WebMethod] attribute over it

public class Employee : WebService
{
[WebMethod()]
public DataSet GetCutomer(int CustomerID)

->
the transport protocol is mainly HTTP, though it can be SMTP or TCP as well
-> SOAP
is the preferred and default message protocol
-> use XML serialization

-An ASMX page contains a complete set of information that describes how the data will be formatted, how to wrap the data in a SOAP header, and how to prepare it to be sent
-ASMX is the tight coupling with the HTTP runtime and the dependence on IIS to host it
-ASMX service is instantiated on a per-call basis, while WCF gives you flexibility by providing various instancing options such as Singleton, private session, per call


[WCF] Summaries II

First Part Here

UDDI is a platform-independent directory protocol for describing services and discovering
and integrating business services via the Internet.
-> like a traditional "yellow page"
-> three parts: the white (details of the company and its contact information), yellow (industry categories), and green (technical details that describe the interface via
a WSDL) pages ;

_________________
Service invocation is a general mechanism for sending messages between an entity that requests a service and another entity that provides the service
1. Find the relevant service that exposes the desired functionality.
2. Find out the type and format of the messages that the service would accept.
3. Understand any specific metadata that might be required as part of the message (for
example, for transaction or security).
4. Send the message to the provider with all relevant data and metadata.
5. Process the response message from the service in the appropriate manner

_________________
Life cycle of an XML web service has eight steps:
1. A client connects to the Internet and finds a directory service to use.
2. The client connects to the directory service in order to run a query.
3. The client runs the relevant query against the directory service to find the web service
that offers the desired functionality.
4. The relevant web service vendor is contacted to ensure the service is still valid and is
available.
5. The description language of the relevant web service is retrieved and forwarded to the
client.
6. The client creates a new instance of an XML web service via the proxy class.
7. The runtime on the client serializes the arguments of the service method into a SOAP
message and sends it over the network to the web service.
8. The requested method is executed, which sets the return value including any out
parameters.
-> web services rely on open web standards (such as SOAP, HTTP, and
XML)
-> support message-based communication by default
-> rely on XML Schema for data types

______________________________
3 main design goals of WCF:
• Unification of existing technologies
• Interoperability across platforms
• Service-oriented development
-> is reference the System.ServiceModel assembly
-> native messaging protocol is SOAP
->
provide explicit service oriented application development
->
A schema is defined in the XML Schema language, and contracts are defined in WSDL
______________________________
A command-line tool called COMSVCConfig.exe lets an existing
COM+ application spit out a WCF stub to interoperate with COM+ applications.

______________________________
A component is compiled code.
-> Ease of reusability, maintenance, and lower application costs
-> you can use components to build services

______________________________
WCF and SOA



















______________________________________
Endpoint
= what this service can do, how can it be accessed, and where it is available
-> One service can have multiple endpoints. Each of these endpoints can differ in the address, binding requirements, or contract getting implemented.
___________________________________
BizTalk Server
provides business process orchestration, message transformation, business activity monitoring, and more, through designers and visual tools
-> is responsible for orchestrating WCF services

___________________________________
Some of the WS-* suite of protocols are HTTP, standards-based XML, SOAP, WSAddressing, and Message Transmission Optimization Mechanism (MTOM).
-> Microsoft has been generous enough to providethe class library on the top of the .NET Framework called WSE that encapsulates the implementations details and provides an easy-to-use API to consume these specifications

___________________________________
svcTraceViewer.exe
->
WCF has also come up with end-to-end tracing through a trace viewer
-> also with message logging in the XML
files.
______________________________________
ABCs of WCF = Service endpoints that are the combination of address, binding, and contract
Endpoints
either can be defined in the code or can be defined in the configuration file.
The heart of WCF
lives inside the System.ServiceModel namespace and the messaging system underneath it.

ABC stands for address, binding, and contract:
The address specifies where the messages can be sent (or where the service lives).
• The binding describes how to send the messages.
• The contract describes what the messages should contain.
-> ABC = endpoint
__________________________________
Precedence in WCF:
1. Attributes are applied.
2. The configuration is applied.
3. The code runs.

A WSDL file describes what a service can do, how a service can be accessed, and where the service can be found.






luni, 5 octombrie 2009

[WCF] Summaries I

WCF

[ServiceContract]
[OperationContract]

WsHttpBindings
.HostNameComparationMode
->
HostNameComparationMode.Strong
.Security.Mode
->SecurityMode.None

ServiceHost _sh = new ServiceHost(typeof(MyService), _baseAddress);
.DescriptorBehavior.Find()
.AddServiceEndpoint()
.Open();

ServiceMetadataBehavior
.HttpGetEnabled
.MetadataExporter


ChannelFactory
.
CreateChannel()
((IChannel)_channel).Close();
_________________________________________________________

svcutil /:t metadata http://localhost:8000/MyService
->
results 3 files:
  • schema.microsoft,com.2003.10.Serialization.xsd
  • tempuri.org.wsdl
  • tempuri.org.xsd
_________________________________________________________

A service is an autonomous (business) system that accepts one or more requests and returns one or more responses via a set of published and well defined interfaces.

Tenet 1: Boundaries Are Explicit
- A well-defined and published public interface
- easy to consume
- use explicit messages
- Keep the service surface area small
- Don’t expose implementation details

Tenet 2: Services Are Autonomous
• Contracts, once published, should not be changed.
____________
BPEL -
Business Process Execution Language -- is a business process language that is based on XML and built using web service standards.

Tenet 3: Services Share the Schema and Contract, Not the Class
Tenet 4: Service Compatibility Is Based on Policy

____________
A component is a piece of compiled code that can be assembled with other components to build applications.
A service is implemented by one or more components and is a higher-level aggregation than a component.
_____________
XSD - XML Schema Definition
WS - MetadataExchange = MEX
-> message to retrieve
_____________

SOAP
= Simple Object Access Protocol
- it is extensible
- works across a no. of standardized underlying netw. protocols
- independent of language/platform/programming model
- can use one of many standard protocols (TCP, SMNP, FTP, MSMQ...)
_____________

Message (SOAP)
  • envelope
  • header (individual headers) & body (Message Name & Data, Fault)
  • 3 types: request msg. , response msg., fault msg
  • has Protocol Header (HTTP, SMNP,...)













_____________

WSDL ("whiz-dull")
- describe service endpoints
- standardization for specifying interfaces and allows for integration













_____________
Endpoint - “an association between a fully specified interface binding and a network address, specified by a URI that may be used to communicate with an instance of a web service.”
- ~~ port
- Service = collection of endpoints

____________
WSDL Document Structure

Operations performed by the web service
- message -- Message used by the web service
- types -- Data types used by the web service
- binding -- Defines a communication endpoint (by means of protocol and address)
to access the service
- Service -- Aggregates multiple ports (in combination with binding and address
into a service)
____________