-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Homework Added
- Loading branch information
Showing
57 changed files
with
2,177 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## XML Basics | ||
### _Homework_ | ||
|
||
1. What does the XML language represents? What is it used for? | ||
1. Create XML document `students.xml`, which contains structured description of students. | ||
* For each student you should enter information for his name, sex, birth date, phone, email, course, specialty, faculty number and a list of taken exams (exam name, tutor, score). | ||
1. What do the namespaces represent in the XML documents? What are they used for? | ||
1. Explore http://en.wikipedia.org/wiki/Uniform_Resource_Identifier to learn more about URI, URN and URL definitions. | ||
1. Add default namespace for the students "`urn:students`". | ||
1. Create XSD Schema for the `students.xml` document. | ||
* Add new elements in the schema: information for enrollment (date and exam score) and teacher's endorsements. | ||
1. Write an XSL stylesheet to visualize the students as HTML. | ||
* Test it in your favourite browser. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<?xml-stylesheet type="text/xsl" href="students.xsl" ?> | ||
|
||
<students xmlns:students="urn:students" | ||
xmlns:student="urn:students:student" | ||
xmlns:exams="urn:students:student:exams" | ||
xmlns:exam="urn:students:student:exams:exam"> | ||
<students:student> | ||
<student:firstName>Pesho</student:firstName> | ||
<student:lastName>Ivanov</student:lastName> | ||
<student:gender>Male</student:gender> | ||
<student:birthDate>1974-09-17</student:birthDate> | ||
<student:phone>+359888123456</student:phone> | ||
<student:email>peshoivanov@gmail.com</student:email> | ||
<student:course>DSA</student:course> | ||
<student:specialty>Academy Ninja</student:specialty> | ||
<student:facultyNumber>55667788</student:facultyNumber> | ||
<student:exams> | ||
<exams:exam id="csharp"> | ||
<exam:name>CSharp</exam:name> | ||
<exam:tutor>Csharp Guru</exam:tutor> | ||
<exam:score>85</exam:score> | ||
</exams:exam> | ||
<exams:exam id="javascript"> | ||
<exam:name>Java Script</exam:name> | ||
<exam:tutor>JS Guru</exam:tutor> | ||
<exam:score>93</exam:score> | ||
</exams:exam> | ||
<exams:exam id="hqc"> | ||
<exam:name>High Quality Code</exam:name> | ||
<exam:tutor>HQC Master</exam:tutor> | ||
<exam:score>72</exam:score> | ||
</exams:exam> | ||
<exams:exam id="databases"> | ||
<exam:name>Databases</exam:name> | ||
<exam:tutor>DB Wizard</exam:tutor> | ||
<exam:score>88</exam:score> | ||
</exams:exam> | ||
</student:exams> | ||
</students:student> | ||
<students:student> | ||
<student:firstName>Mariika</student:firstName> | ||
<student:lastName>Petrova</student:lastName> | ||
<student:gender>Female</student:gender> | ||
<student:birthDate>1982-11-02</student:birthDate> | ||
<student:phone>+359888567890</student:phone> | ||
<student:email>mariikapet@gmail.com</student:email> | ||
<student:course>JS SPA</student:course> | ||
<student:specialty>Front-End</student:specialty> | ||
<student:facultyNumber>11223344</student:facultyNumber> | ||
<student:exams> | ||
<exams:exam id="html"> | ||
<exam:name>HTML</exam:name> | ||
<exam:tutor>HTML Guru</exam:tutor> | ||
<exam:score>93</exam:score> | ||
</exams:exam> | ||
<exams:exam id="javascript"> | ||
<exam:name>Java Script</exam:name> | ||
<exam:tutor>JS Guru</exam:tutor> | ||
<exam:score>99</exam:score> | ||
</exams:exam> | ||
<exams:exam id="css"> | ||
<exam:name>CSS</exam:name> | ||
<exam:tutor>CSS Master</exam:tutor> | ||
<exam:score>87</exam:score> | ||
</exams:exam> | ||
<exams:exam id="jsapps"> | ||
<exam:name>JS Applications</exam:name> | ||
<exam:tutor>JS Wizard</exam:tutor> | ||
<exam:score>91</exam:score> | ||
</exams:exam> | ||
<exams:exam id="jsuidom"> | ||
<exam:name>JS UI and DOM</exam:name> | ||
<exam:tutor>JS Guru</exam:tutor> | ||
<exam:score>97</exam:score> | ||
</exams:exam> | ||
</student:exams> | ||
</students:student> | ||
</students> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<xs:schema targetNamespace="urn:students" | ||
elementFormDefault="qualified" | ||
xmlns:xs="urn:students" | ||
xmlns:student="urn:student" | ||
xmlns:exam="urn:students:student:exams" | ||
> | ||
<xs:element name="students"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
|
||
<xs:element name="student" maxOccurance="unbound"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element name="firstName" type="xs:string"/> | ||
<xs:element name="lastName" type="xs:string"/> | ||
|
||
<xs:element name="gender"> | ||
<xs:simpleType> | ||
<xs:restriction base="xs:string"> | ||
<xs:enumaration value="Male"/> | ||
<xs:enumeration value="Female"/> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
</xs:element> | ||
|
||
<xs:element name="birthDate" type="xs:date"/> | ||
|
||
<xs:element name="phone"> | ||
<xs:simpleType> | ||
<xs:restriction base="xs:string"> | ||
<xs:pattern value="+359[7-9]{3}[0-9]{6}"/> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
</xs:element> | ||
|
||
<xs:element name="email"> | ||
<xs:simpleType> | ||
<xs:restriction base="xs:string"> | ||
<xs:pattern value ="^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$"/> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
</xs:element> | ||
|
||
<xs:element name="course" type="xs:string"/> | ||
<xs:element name="specialty" type="xs:string"/> | ||
|
||
<xs:element name="facultyNumber"> | ||
<xs:simpleType> | ||
<xs:restriction base="xs:integer"> | ||
<xs:minInclusive value="100000"/> | ||
<xs:maxInclusive value="999999"/> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
</xs:element> | ||
|
||
<xs:element name="exams"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element name="exam" maxOccurance="unbound"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element name="name" type="xs:string"/> | ||
<xs:element name="tutor" type="xs:string"/> | ||
<xs:element name="score" type="xs:integer"/> | ||
<xs:element name="enrollmentDate" type="xs:date"/> | ||
<xs:element name="endorsements" type="xs:integer"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:element> | ||
|
||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
<xsl:template match="/"> | ||
<html> | ||
<body> | ||
<h2>Students</h2> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>First Name</th> | ||
<th>Last Name</th> | ||
<th>Gender</th> | ||
<th>Bith Date</th> | ||
<th>Phone</th> | ||
<th>E-mail</th> | ||
<th>Course</th> | ||
<th>Specialty</th> | ||
<th>Faculty Nr.</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<xsl:for-each select="/students/student"> | ||
<tr> | ||
<td> | ||
<xsl:value-of select="firstName"/> | ||
</td> | ||
<td> | ||
<xsl:value-of select="lastName"/> | ||
</td> | ||
</tr> | ||
</xsl:for-each> | ||
</tbody> | ||
</table> | ||
</body> | ||
</html> | ||
</xsl:template> | ||
</xsl:stylesheet> |
99 changes: 99 additions & 0 deletions
99
...uality-Code/17. Design Patterns/Behavioral/Chain-Of-Responsibilities-Pattern.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#Верига на отговорността/Chain of Responsibility | ||
|
||
###1. Description | ||
Този шаблон се използва в случаи, когато има променлив брой обработващи елементи или възли и постоянен поток от заявки, които трябва да се обработят. Той помага да се избегне свързването на определена заявка с определен обработващ елемент и логическото взаимосвързване между обработващите елементи. | ||
|
||
Шаблонът свързва във верига всички елементи получатели , и след това предава дадена заявка (съобщение) от елемент на елемент докато достигне такъв, който може да я обработи. Броят на получаващите елементи не се знае предварително а може да се конфигурира в последствие. | ||
Веригата на отговорността опростява връзката между изпращият и получаващият елемент. Вместо те да поддържат референции към всички кандидат-получатели, всеки изпращащ елемент поддържа референция към началото на веригата а всеки получаващ елемент поддържа единствена референция към своят пряк нселдник във веригата. | ||
|
||
При употребата на този шаблон трябва да се подсигури съществуването на предпазна мрежа, която да хване всички необработени заявки. | ||
|
||
###2. Diagram | ||
![Diagram][diagramlink] | ||
[diagramlink]:https://sourcemaking.com/files/v2/content/patterns/Chain_of_responsibility1-2x.png | ||
|
||
###3. Sample Code | ||
```csharp | ||
using System; | ||
|
||
class MainApp | ||
{ | ||
static void Main() | ||
{ | ||
Handler h1 = new ConcreteHandler1(); | ||
Handler h2 = new ConcreteHandler2(); | ||
Handler h3 = new ConcreteHandler3(); | ||
h1.SetSuccessor(h2); | ||
h2.SetSuccessor(h3); | ||
|
||
int[] requests = {2, 5, 14, 22, 18, 3, 27, 20}; | ||
|
||
foreach (int request in requests) | ||
{ | ||
h1.HandleRequest(request); | ||
} | ||
|
||
Console.Read(); | ||
} | ||
} | ||
|
||
abstract class Handler | ||
{ | ||
protected Handler successor; | ||
|
||
public void SetSuccessor(Handler successor) | ||
{ | ||
this.successor = successor; | ||
} | ||
|
||
public abstract void HandleRequest(int request); | ||
} | ||
|
||
class ConcreteHandler1 : Handler | ||
{ | ||
public override void HandleRequest(int request) | ||
{ | ||
if (request >= 0 && request < 10) | ||
{ | ||
Console.WriteLine("{0} handled request {1}", | ||
this.GetType().Name, request); | ||
} | ||
else if (successor != null) | ||
{ | ||
successor.HandleRequest(request); | ||
} | ||
} | ||
} | ||
|
||
class ConcreteHandler2 : Handler | ||
{ | ||
public override void HandleRequest(int request) | ||
{ | ||
if (request >= 10 && request < 20) | ||
{ | ||
Console.WriteLine("{0} handled request {1}", | ||
this.GetType().Name, request); | ||
} | ||
else if (successor != null) | ||
{ | ||
successor.HandleRequest(request); | ||
} | ||
} | ||
} | ||
|
||
class ConcreteHandler3 : Handler | ||
{ | ||
public override void HandleRequest(int request) | ||
{ | ||
if (request >= 20 && request < 30) | ||
{ | ||
Console.WriteLine("{0} handled request {1}", | ||
this.GetType().Name, request); | ||
} | ||
else if (successor != null) | ||
{ | ||
successor.HandleRequest(request); | ||
} | ||
} | ||
} | ||
``` |
Oops, something went wrong.