Вы находитесь на странице: 1из 315

.

. .

.
. .



.
Web-
Java .NET, .
,


.
J2EE .NET.

..............................................................................................................................................1
..................................................................................................................................4
......................................................................................................................................6
.............................................................................................................................................7
1. ......................................................9
.............................................................................................9
...................................................................................14
1......................................................................................................................20
2. ...................................................................21
........................................................................................................21
..........................................................................................................23
ISO..................................................................................................................23
IEEE ...............................................................................................................26
CMM, SEI............................................................................26
................................................................................................................30
2......................................................................................................................33
3. ..............35
.................................................................................35
Rational ...............................................................................................35
..................................................................................................44
3......................................................................................................................47
4. ..............................................................48
.............................................................................................................48
......................................................................................................53
..................................................................................................................56
4......................................................................................................................59
5. .................................................................................60
..............................................................................................60
...............................................................................................................66
..................................................................................................................................67
.....................................................................................................................70
.......................................................................................................................71
5......................................................................................................................73
6. ..........................................................................75
..................................................................................................................75
........................................................................................75
................................................................79
1

UML. UML..............................................................................................................83
................................................................................................................83
............................................................................................................87
6......................................................................................................................90
7. ....................................................................................................91
..............................................................................................91
................................................................................................................................94
........................................................................................................................96
.........................................................................................................................99
............................................................................................................102
7....................................................................................................................106
8. ()........................................................................107
............................................................................................107
................................................................................................................111
....................................................................................................................................111
.............................................................................................................................................113
.......................................................................................................................113
.................................................................................115
................................................................................................116
8....................................................................................................................118
9. .....................................119
.................................................................119
............................................................................121
..............................................................................................121
.......................................................................122
......................................................................................................................124
...................................................................................................................................125
...........................................................................................................................126
...............................................................................................127
....................................127
.........................................................130
...........................................................................134
9....................................................................................................................136
10. Java C#......................................................................138
Java .NET ..................................................................................................................138
.............................................................................................................................................140
.........................................................................................................143
..............................................................................................147
............................................................................................................................147
...................................................................................................................148
...............................................................................................150
...............................................................................................................151
....................................................................................................................................151
..................................................................................................................................155
...................................................................................................................163
10..................................................................................................................172
11. Java C# () ...........................................174
...............................................................................................................................174
...........................................................................................................................176
.....................................................................................................191
.......................................................................194
.................................................................................................................196
..............................................................................198
.......................................................................................................................................201
2

11..................................................................................................................209
12. ..................................210
............................................................................210
...............................................................214
................................................................................218
.......................................................................................................................................222
12..................................................................................................................224
13. Web- ..........................................226
Web-..............................................................................................................................226
XML ................................................................................................227
Java 2 Enterprise Edition...............................................................................................228
..............................................................................................................................................230
..................................................................................................................................233
........................................................................................................235
..................................................................................................................................235
....................................................................................................................236
...........................................................................................................................................236
XML ...............................................................................................................................237
.NET ..............................................................................................................................238
..............................................................................................................................................238
..................................................................................................................................241
........................................................................................................241
..................................................................................................................................241
....................................................................................................................242
...........................................................................................................................................242
XML ...............................................................................................................................242
13..................................................................................................................243
14. Web- J2EE .NET ..............................244
Web-...........................................................................................244
- J2EE.........................................................................245
........................................................................246
, .................................................................................252
EJB .......................................................................253
.NET .....................................................................................................257
HTTP................................................................................................................................258
J2EE...........................................................................260
.......................................................................................................................................261
Java ...........................................................................................................262
.NET ..........................................................................267
14..................................................................................................................269
15. ..............................................................................270
J2EE ..............................................................................................................270
Jakarta Struts..................................................................................................................................271
Java Server Faces...........................................................................................................................273
. Hibernate...........................................................................273
Java Data Objects ..........................................................................................................................276
Enterprise Java Beans 3.0 ..............................................................................................................276
Spring .................................................................................................................................276
Ajax................................................................................................................................................278
Web- .....................................................................................................................................279
Web- .............................................................................................280
..............................................................................................................................................281
..................................................................................................................................281
......................................................................................................................................282
3

....................................................................................................282
....................................................................................................................282
...........................................................................................................................................283
15..................................................................................................................283
16. ...........................................................................................285
........................................................................................................285
..........................................................................................................................288
- ..........................................................................288
.........................................................................................................289
.............................................................................................290
, ...............................................................291
.......................................................................293
.................................................................................................................................294
................................................................................................................298
..........................................................................................301
....................................................................................................................308
........................................310
16..................................................................................................................313


1. . ..................................................................................8
2. , ............................................29
3. . ..............31
4. , [13].......................................................................31
5. ...................................................................32
6. [15].........................................33
7. .........................................................................36
8. . ......................................................................37
9. . ..............................................................................37
10. . ..............................................................................38
11. RUP ............................39
12. . ....................................................40
13. . ........................................40
14. RUP.................43
15. XP. ....................................................................................................45
16. -. ........................................50
17. -. ..............................................51
18. " ". ...........................................................52
19. . ...............................................................................................52
20. , , . ........54
21. -. .....................57
22. -................58
23. ISO 9126. ...................................................................61
24. ISO 9126. ...................................................63
25. . ............................................................................................68
26. . ..........................................................70
27. ...........................................................................77
28. ....................................................................................81
29. ....................................................81
30. . ...............................................................82
31. . ..............................................................................................................84
32. .............................................................................................................85
33. ......................................................................................................86
4

34. . ..................................................................................................86
35. .........................................................................................................87
36. ...................................................................88
37. , . 36. ..........88
38. , -. ....................89
39. - ...............................................................92
40. , ....................94
41. . .................95
42. . ..................................................................95
43. ..............................................95
44. , . .....96
45. . .........................................100
46. . ................................................................100
47. . ....................................................................100
48. ....................................101
49. .. ...............................................................103
50. . .....................................................104
51. , . ...........................................108
52. ...................................................................108
53. ...................................................................................109
54. ....................................................................111
55. .......................................112
56. . ............................................................................114
57. ? ? ......................................................................121
58. 11,3 ?...............................................................................122
59. MacOS , Windows ..............................123
60. . "" Next . ..........................................................126
61. ..........................................................................131
62. ..............................................132
63. Microsoft Word..........................................................133
64. . ............................................134
65. . ...............................213
66. . ............................................................................................218
67. , RPC......................219
68. ..........................................................220
69. . ..........................................................................................221
70. . ..........222
71. ..........................................223
72. J2EE ...........................................................................230
73. Web- .NET................................................238
74. Web- J2EE .NET. ..........................................244
75. EJB . .....................................................................248
76. . ...............................................248
77. . ..............................................249
78. . ..............................................................................................................249
79. Web- Struts......................................272
80. . ..............................................274
81. Web-. ...............................................279
82. . ..................................291
83. , ........293
84. , . .....................294
85. . .........................295
86. . ...............................................................................298
87. PERT- . ...........................................299
5

88. ............................................300
89. , .......300
90. . ......................................................302
91. . ............................................................................303
92. . ..................................305
93. . .....................................................................313


1. ISO 12207. .................................................................23
2. ISO 15288. ...........................................................24
3. ISO 15504. .................................................25
4. CMM 1.1..........28
5. . . ............................49
6. . .................................................83
7. ..........................................................................................98
8. . ...............................117
9. .......................................132
10. . .....................................................................152
11. XML...............................................................228
12. HTTP . ...............................................259
13. , . 86.................................299


,

. . . .
, . .
().
, ,

Web-.
,
,
,
.
. ,
, .
,
.
(middleware)

, ,
.
.
,
.
, ,
, , ,
, .
,
, - , . ,
,
, , ,
.
- , , . ,
, . , ,

,
,
, .

. , ,
, .
. 1.
, ,
, .
,
, , ,
, ,
.
7

16

15

12

10

13

11

14

1. .


: . . , . .
,
. . , . .
4 ,
. . ,
, . .
,
.

1.

.
.
,
.


, , ,
, , , ,
, , , .



.
- ,
, ,
, ,
.
, ( ,
30000) .
.
arctan(x) = x x3/3 + x5/5 x7/7 + + (-1)nx2n+1/(2n+1) + O(x2n+3)
/4 = arctan(1) = 4*arctan(1/5) arctan(1/239)
Java .
public class PiCalculator
{
//
// <= 42949 = ( 2^32 mod CLUSTER_SIZE )
// 10 .
private final static long CLUSTER_SIZE = 100000;
//
// numberOfClusters * lg( CLUSTER_SIZE )
// .
private static int numberOfClusters;
private static void print(long a[])
{
for(int i = 0; i < numberOfClusters + 1; i++)
{
if (i == 0) System.out.print("" + a[i] + '.');
else
{
StringBuffer s = new StringBuffer();
long z = CLUSTER_SIZE/10;

while(z > 0)
{
if (z > a[i]) { s.append(0); z /= 10; }
else
break;
}
if (z != 0) s.append(a[i]);
System.out.print(s);

}
System.out.println();

private static void lndiv(long a[], int n)


{
for(int i = 0; i < numberOfClusters + 1; i++)
{
if (i != numberOfClusters)
{
a[i+1] += (a[i]%n)*CLUSTER_SIZE;
a[i] /= n;
}
else a[i] /= n;
}
}
private static void lnadd(long a[], long b[])
{
for(int i = numberOfClusters; i >= 0; i--)
{
if (i != 0)
{
a[i-1] += (a[i] + b[i])/CLUSTER_SIZE;
a[i] = (a[i] + b[i])%CLUSTER_SIZE;
}
else
a[i] = (a[i] + b[i])%CLUSTER_SIZE;
}
}
private static void lnsub(long a[], long b[])
{
for(int i = numberOfClusters; i >= 0; i--)
{
if (i != 0)
{
if (a[i] < b[i]) { b[i-1]++; a[i] += CLUSTER_SIZE; }
a[i] -= b[i];
}
else
a[i] -= b[i];
}
}
public static void main (String[] args)
{
int i, j, numberOfDigits = 100, numberOfSteps;
if (args.length > 0) numberOfDigits = Integer.parseInt(args[0]);
numberOfSteps = (int)(((numberOfDigits + 1)/(Math.log(5)/Math.log(10)) - 1)/2+1);
numberOfClusters = (int)(numberOfDigits/(Math.log(CLUSTER_SIZE)/Math.log(10))+1);
long
long
long
long
long
long

a1[]
b1[]
c1[]
a2[]
b2[]
c2[]

=
=
=
=
=
=

new
new
new
new
new
new

long[numberOfClusters
long[numberOfClusters
long[numberOfClusters
long[numberOfClusters
long[numberOfClusters
long[numberOfClusters

+
+
+
+
+
+

1];
1];
1];
1];
1];
1];

a1[0] = 16;
a2[0] = 4;
lndiv(a1, 5);
lndiv(a2, 239);

10

System.arraycopy(a1, 0, c1, 0, numberOfClusters + 1);


System.arraycopy(a2, 0, c2, 0, numberOfClusters + 1);
for(j = 1; j < numberOfSteps; j++)
{
lndiv(a1, 25);
lndiv(a2, 239);
lndiv(a2, 239);
System.arraycopy(a1, 0, b1, 0, numberOfClusters + 1);
System.arraycopy(a2, 0, b2, 0, numberOfClusters + 1);
lndiv(b1, 2*j+1);
lndiv(b2, 2*j+1);
if (j%2 == 0) { lnadd(c1, b1); lnadd(c2, b2); }
else
{ lnsub(c1, b1); lnsub(c2, b2); }
}
lndiv(a1, 25);
lndiv(a1, 2*numberOfSteps + 1);
System.out.println(" :");
print(a1);
lnsub(c1, c2);

System.out.println(":");
print(c1);

, (~150 ), :
( )
( 30000 ), ,
- .
, 30000
, .
(
, ,
).
,
.

, ,
, , .
, ,
, ,
( ),
,
,
.
.
,
, - ,
.
, . ,
, ,
11

,
.

.

, .

- , .
, , ,
, .
, , ,
, ,
().
( 5- ).
,
.
, ,
.
Java,
Java Development Kit [1].
, ,
, -
, .
,

, .
,
. ,
, , ,
.
,
. .
,
. ,
,
. ,
,
,
, .
,
,
(, ,
). .
,
,
,
, ,
, ..
,
.
12

,
.
.
, ,
, , ..
.
, ,
.
,
, .
, ,
,
.

.
,
, .
(, , )
,
, , ,
, , .

.
() , . ,
-
. ,
.
, ,
, .
,
-
. ,
,
. , ,
, , , ,
.
,
, ,
, , ,
.
J2EE .NET.
, ,
, ,
, .

,
. ,
, ,
,
, ,
.
13

. ,

.
, , ,
,
, , - ,
. , ,
,
, .

.


(Agile Software Development).
,
(Extreme Programming, XP).
.


,
.

.

.
,
.
(abstraction) (refinement).
.

. ,
- ,
.
- - ,
, .. ,

, .
,
.
, ,

, .
, ,
, .
.
-
, , ,
, - -.
, , ,
- (. [2], 14, III JDK
java.util.TreeSet java.util.TreeMap).
14

.
,

.
, - ,
, ,
. .

, ..
. , , TCP,
, .
,
, .. -
.
(
, ), (

)
(
, ,
).
(modularity).
,
.
,
. , ,
, , ,
, .
,
,
, .
,
,
, .
.

JDK. , Java ,
java.lang.
, , , .,
java.util. , -
java.io, ..
,
.
.

. , ,
. ,
.
:
. ,
, ..
.
15

, . -
.
.
.
o .

,
.
,
.
, java.util.Queue<type E>,
E, .
E element()
, ,
. NoSuchElementException,
.
boolean offer(E o)
, , .
true, , false
.
E peek()
, ,
. null, .
E poll()
, ,
. null, .
E remove()
, ,
. NoSuchElementException,
.
, ,
PriorityBlockingQueue<E> .
,
.
, ,
.
package java.util.concurrent;
import java.util.concurrent.locks.*;
import java.util.*;
public class PriorityBlockingQueue<E> extends AbstractQueue<E>
implements BlockingQueue<E>, java.io.Serializable {
private static final long serialVersionUID = 5595510919245408276L;
private final PriorityQueue<E> q;
private final ReentrantLock lock = new ReentrantLock(true);
private final ReentrantLock.ConditionObject notEmpty =
lock.newCondition();
public PriorityBlockingQueue() { ... }
public PriorityBlockingQueue(int initialCapacity) { }
public PriorityBlockingQueue(int initialCapacity,
Comparator<? super E> comparator) { }
public PriorityBlockingQueue(Collection<? extends E> c) { ... }
public boolean add(E o) { ... }
public Comparator comparator() { }
public boolean offer(E o) { }
public void put(E o) { }
public boolean offer(E o, long timeout, TimeUnit unit) { }
public E take() throws InterruptedException { }

16

public E poll() { }
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
}
public E peek() { }
public int size() { }
public int remainingCapacity() { }
public boolean remove(Object o) { }
public boolean contains(Object o) { }
public Object[] toArray() { }
public String toString() { }
public int drainTo(Collection<? super E> c) { }
public int drainTo(Collection<? super E> c, int maxElements) { }
public void clear() { }
public <T> T[] toArray(T[] a) { }
public Iterator<E> iterator() { }
private class Itr<E> implements Iterator<E> {
private final Iterator<E> iter;
Itr(Iterator<E> i) { }
public boolean hasNext() { }
public E next() { }
public void remove() { }
}
private void writeObject(java.io.ObjectOutputStream s)
throws java.io.IOException { }
}

o , , .
,
.
,
, .
, ,
,
,
. ,
,
.
,
.
, offer()
, ,
.
element() peek(). ,
, ,
.

.
,

(
).
element()
peek(), poll() remove() .
17

, ,
element() remove().
,
. ,

, ,
.

,
. ,
, ,
, , ,
, .
,

,
.
, Object
queue(Object o, boolean remove), ,
, null,
( null, ) ,
true. , ,
.
o .

,
.
.
java.util.Date , .
,
.

(, 22:32:00, June 15, 2005) ,
, java.util.GregorianCalendar,
.

java.util.Calendar,
.

java.text.SimpleDateFormat, ,
, ,
,
(, 22:32:00, June 15, 2005 05.06.15, 22:32).
.
.
,
,
, .
, , ,

java.text.SimpleDateFormat.
.
.
18

, ,
. , ,
,
.
.
,
, , .

java.util.List<E> , ,
java.util.ArrayList<E>, java.util.LinkedList<E>.
,
.
o (coupling) (cohesion)
.

. ,
. ,
, ,
, .
, , ,
.
, ,
.
. ,
.
, void println(String),
.
, . ,

.
.
.

, , , .
,

, .
(,
)
,
.
java.util.TreeSet
java.util.TreeMap. ,
, .
(map), .
,
.
JDK Sun, ,
TreeSet TreeMap,
, (,
) null.

19

1
[1] Java http://java.sun.com/docs/index.html
[2] . , . , . . : . .: , 1999.
[3] . . . .: , 2002.
[4] . , . . -. .: , 2004.
[5] . . . : . .:
, 2001.
[6] . . -
C++. . .: , .: , 2000.
[7] F. Buschmann, R. Meunier, H. Rohnert, P. Sommerlad, M. Stal. Pattern-Oriented Software
Architecture. Wiley, 2002.

20

2.

.
,
, ,
.


, , ,
, , , ,
, ,
, .



,
. .

: ,
, ,
, .
. ,
,
.
,
, , .. ,

.
,
,

, ,
,
.

, ,
,
, ,
. , ,
,
,
.
,
,
. ,
, , ,
, //

, , ,
.
21

, ,
, , , . .
,

.

, ,
.
: , ,
, , ,
, , , ,
, ,
, , .
,
.
,
.
: -, , ,
, -, ,
, , ,
, , ..
, ,
, ,
.
, ,
,
, . ,

.
( ), , ,
.
, ,
, ,
,
,
.
-
, .
.
,
- .
,
, , ,
, .
,
.
, ( )
, , ,
, . ,
, ,
.
22


,
, .
, , :
IEEE --, Institute of Electrical and Electronic Engineers,
;
ISO International Standards Organization, ;
EIA Electronic Industry Association, ;
IEC International Electrotechnical Commission,
;
( ,
,
):
ANSI American National Standards Institute,
;
SEI Software Engineering Institute, ;
ECMA European Computer Manufactures Association,
;
,
. .

ISO

ISO/IEC 12207 Standard for Information Technology Software Life Cycle Processes [1]
( , -1999 [2]).
3- ,
, .
,
, ,
,
.
(lifecycle
processes). 18 , 4 .

;
(
);
;
;

;
;
;
;
;
;
;

1. ISO 12207.

(activities).
74 , .
.
o , ,
, , ,
.
23

o ,
, (-) ,
, , ,
, ,
, , ,
( ) , .
o ,
, ,
, ,
.
o , ,
, ,
.
(tasks).
224 . :
o ,
,
, .
o ,
, .
ISO/IEC 15288 Standard for Systems Engineering System Life Cycle Processes [3]
( ).
-
.

.
ISO/IEC 15288
. (outcomes),
.
26 , 5 .

;
;
;
;

;
;

;
;
;
;
;

;
;
;

2. ISO 15288.

24

, 123 208 ,
. ,
.
o , .
o .
.
o .
o , .
o .
o .
o .
o .
o .
o .
o .
ISO/IEC 15504 (SPICE) Standard for Information Technology Software Process
Assessment [4] ( ).
,
CMMI (. )
.
,
. ,
.
5 , 35 201 .

;

;


;

;

;

;
;

;
,

;

3. ISO 15504.

, ,
, , ,
, .
25

IEEE

IEEE 1074-1997 IEEE Standard for Developing Software Life Cycle Processes [5]
( ).
,
. ,
, , , .
,
, .
5 , 17 65 .
,
, .
, ,
, .
IEEE/EIA 12207-1997 IEEE/EIA Standard: Industry Implementation of International
Standard ISO/IEC 12207:1995 Software Life Cycle Processes [6-8] (
ISO/IEC 12207 ).
ISO/IEC 12207, J-Std-016-1995 EIA/IEEE
Interim Standard for Information Technology Software Life Cycle Processes Software
Development Acquirer-Supplier Agreement (
)
MIL-STD-498.

CMM, SEI

CMM (Capability Maturity Model) [9,10]



. 3 :
(maturity levels), (key process areas)
(key practices). CMM
. CMM CMMI
(. ).
o .
CMM , 5
.
1, (initial).
, ,
, .
2, (repeatable).
,
, .
3, (defined).
, ,

. ,
, .
4, (manageable).
, ,
,
(, ,
), .
5, (optimizing).
, ,
,
26

,
.
o .
CMM,
,
.
, ,
. 18 .
, ,
.
.

, , ,
, , .
, ,
, ,
,
, ,
,
.
:
, .

,
.
o .
.
:
(commitments to perform), (abilities to perform), (activities
performed), (measurements and analysis) (verifying
implementations).
, .
.

.
.

,
.
.

.
.
.
,
, , .

.
.

27

.

.
.

.

.

.
4 ,
.




1
4
3
1
3

2
4
15
1
3

2
5
13
1
3

2
3
13
1
3

1
4
8
1
3

1
5
10
1
4

3
4
7
1
1

1
2
6
1
1

1
4
6
2
3

1
3
11
1
3

1
4
10
2
3


1
5
7
1
3

1
3
3
1
1


2
5
7
1
3

1
3
5
1
3

2
4
8
1
3

3
5
8
1
2

2
4
10
1
2

4. CMM 1.1.

CMMI (Capability Maturity Model


Integration) [11,12].
CMM
, - .
CMM .
o .

EIA/AIS 713
28

.
CMM .
o ,
(required), (expected) (informative).
o (generic) (specific).
,
.
o .
(managed), (quantitatively
managed).
o .
4 .
,
CMMI.
.
(3), (3),
(3), (4), (5).
.
(2), (2),
(2), (3),
(3), (3), (3)
(4).
.
(3), (2),
(3), (3), (3)
(3).
.
(2),
(2), (2),
(3), (3), ,
(5).
, . 2 (
, ,
).
MIL-STD-498
( )

J-Std-016-1995
( )

IEEE 1074

IEEE/EIA 12207

ISO/IEC 12207

CMM

ISO/IEC 15504 (SPICE)

CMMI

IEEE

ISO
SEI,

2. , .

,
,
29

.
,
.
,
, ,
. , ,
.
. (2005 )
, ,
, .
,
, , .
, DoD-Std-2167,
(. )
.
,
( .. ,
- , ,
), .
, ,
.
ISO IEEE
,
. , ,

.
, ,
,
.


,
.
, .
,
,
. , ,
,
( ) .
, ,
,
. .
, , .

(waterfall) , , ,
[13]
- XX .
,
, ,
, ,
. , -
. [13]
30

. 3.
:
.

3. .

, [13], ,
, , ,
(. . 4) , -,
,
. ,
, ,
. ,
( , ,
, ,
.).
,

, ,
.

4. , [13].

, ,
(., , [14])
31

,
.
( )
,
.
, .
,
, ,
, -
.
,
, .
,
.

1-

2-

3-

5. .


, .
,
, , ,
, .
,
.

,
, .
,
(Boehm) [15].
,
, ,
, .

, , ,
, .
-
,
, .
32

,
,

6. [15].

. 6 . ,

, .

Rational .

2
[1] ISO/IEC 12207:1995, Information Technology Software life cycle processes, 1995.
Amendments 2002, 2004.
[2] -1999. . .
[3] ISO/IEC 15288:2002, Systems engineering System life cycle processes, 2002.
[4] ISO/IEC 15504-1-9, Information technology Process assessment, Parts 1-9.
15504-1,3,4:2004, 15504-2:2003/Cor 1:2004, TR 15504-5:2004.
[5] IEEE 1074-1997 IEEE Standard for Developing Software Life Cycle Processes, 1997.
[6] IEEE/EIA 12207.0-1996 Industry Implementation of International Standard ISO/IEC 12207:1995,
New York, Mar. 1998.
33

[7] IEEE/EIA 12207.1-1997 Industry Implementation of International Standard ISO/IEC 12207:1995


Software Life Cycle Processes Life Cycle Data, New York, Apr. 1998.
[8] IEEE/EIA 12207.2-1997 Industry Implementation of Int'l Standard ISO/IEC 12207:1995 Software
Life Cycle Processes Implementation Considerations, New York, Apr. 1998.
[9] M. C. Paulk, B. Curtis, M. B. Chrissis, and C. V. Weber. Capability Maturity Model for Software,
Version 1.1, SEI Technical Report CMU/SEI-93-TR-024, Software Engineering Institute,
Pittsburgh, Feb. 1993.
http://www.sei.cmu.edu/pub/documents/93.reports/pdf/tr24.93.pdf
[10] M. C. Paulk, C. V. Weber, S. M. Garcia, M. B. Chrissis, and M. Bush. Key Practices of the
Capability Maturity Model, Version 1.1, SEI Technical Report CMU/SEI-93-TR-025, Software
Engineering Institute, Pittsburgh, Feb. 1993.
http://www.sei.cmu.edu/pub/documents/93.reports/pdf/tr25.93.pdf
[11] Capability Maturity Model Integration (CMMI), Version 1.1. CMMI for Systems Engineering,
Software Engineering, Integrated Product and Process Development, and Supplier Sourcing
(CMMI-SE/SW/IPPD/SS, V1.1). Continuous Representation. SEI Technical Report CMU/SEI2002-TR-011, Software Engineering Institute, Pittsburgh, March 2002.
http://www.sei.cmu.edu/pub/documents/02.reports/pdf/02tr011.pdf
[12] Capability Maturity Model Integration (CMMI), Version 1.1. CMMI for Systems Engineering,
Software Engineering, Integrated Product and Process Development, and Supplier Sourcing
(CMMI-SE/SW/IPPD/SS, V1.1). Staged Representation. SEI Technical Report CMU/SEI-2002TR-012, Software Engineering Institute, Pittsburgh, March 2002.
http://www.sei.cmu.edu/pub/documents/02.reports/pdf/02tr012.pdf
[13] W. W. Royce. Managing the Development of Large Software Systems. Proceedings of IEEE
WESCON, pp. 19, August 1970.
: Proceedings of the 9th International Software Engineering Conference, Computer
Society Press, pp. 328338, 1987.
[14] B. Randell, F. W. Zurcher. Iterative Multi-Level Modeling: A Methodology for Computer
System Design. Proc. IFIP, IEEE CS Press, 1968.
[15] B. Boehm. A Spiral Model of Software Development and Enhancement. Computer, May 1988,
pp. 61-72.
[16] . . . .: , 2002.
[17] . . . .: , 2002.
[18] . . . . .: , 2004.

34

3.

,
Rational (RUP) (XP).


, ,
Rational, , .




Rational (Rational Unified Process, RUP) (Extreme
Programming, XP). ,
, ,
.
RUP ,

. ,
, , , .

, .

, .

,
.
,
. ,
, ,
.
, , (agile)
, .
, .
,
, ,
.

Rational
RUP [1,2] ,
.
RUP ,
Ericsson 70-80- XX . (Ivar Jacobson),
, 1987, Objectory AB
,
. Objectory Rational 1995
(Walker Royce,
), (Philippe Kruchten) (Grady Booch),
(Unified Modeling Language, UML).
35

RUP .
,
(use cases)
,
.

.
, ,
. ,
, (..
), ,
,
.

,
.
UML.
,
( )
.

7. .

RUP 4 ,
. ,
, 4 .
1. (Inception)

.
, ,
, , . ,
, ,
, .
36

10% 5% .
. 7.

8. .

2. (Elaboration)
,
,

.
30% 20% .
. 8.

9. .

3. (Construction)
,
, .
, .
37

50% 65% .
. 9.
4. (Transition)
.
, -,
.
10% 10% .
. 10.

10. .

, ,
, ,
, , .
RUP . 11.
RUP ,
.
UML. .
(Use-Case Model).
,
.
(actors) ,
. , ,
.
, ,
,
.
38

11. RUP .


.
,
, , . .
,
, ,
, , ,
. ,
, , ISBN,
.

-.
, ,
, , ,
, .
, , .
, , ,

- , , ,
.
39

12. .

(Analysis Model).
,
, .
, .
,
. ,
,
.
(boundary classes)
, .
(entity classes) ,
.
, .
(control classes) , -

.
-
: ,
; , ;
,
; .
. 13.

. ,
.

. ,

.


13. .

(Design Model).
.
, ,
, .
.
40

;
;
, J2EE, .NET, COM CORBA;
, , , Oracle MS SQL Server;
, swing
swt Java, MFC gtk; .
, , ,
. , , ,
, -
, . ,
, , ,
.
, , , (,
, ), ,
. , -
.
, ,
(
, , .)
.
, , , J2EE
.NET, ,
.
.
(Implementation Model).
RUP UML
.
,
,
.
. ,
.
.
J2EE, .
(Deployment Model).
,
, ,
, , ., ,
.
, .

, ,
.
Web-
, Web-,
, ,
, , ,
. , ,
, Web-,

.
(Test Model Test Suite).
(test
41

cases) (test scripts).


,
. ,
, ,
,
. ,
, , ,
,
,
.
.

( ).

, .

:
o ,
;
o , ;
o ,
;
o , , ,
.
RUP , ,
.
,
, , ,
, .
(-, Business Modeling)
-,
, ,
, ,
, .

( )
( - -).
.
(Requirements)
, ,
,
.
.
(Analysis and Design)
, ,

.
,
, ,
,
.
42

(Implementation)
,
, .
(Test)
( ),
, ,
, .
(Deployment)

, .
(Configuration and Change Management)
,
,
, .
(Project Management)
, ,
, ,
.
(Environment)
,
, .
, .
, RUP,
, . 14.

14. RUP.

, RUP [3].
(project vision) .
.
,
.
43

,
.
.
.
, .
.
, .
, .
.
.


(Extreme Programming, XP) [4]
-.
(Agile Development Method). ,
, SCRUM, DSDM (Dynamic Systems Development
Method, ), Feature-Driven Development (,
) .

[5], 2000 .
, , , .
, .
, .
, .
,
,
,
,
, , , CMM.
,
,
.

.

,
.
, XP (, ,

), . 15.
XP, -
, .
, XP,
(Kent Beck) [4], ,
(Ward Cunningham), (Ron Jeffries).
(planning game)
,
. , ,
(.. , ,
44

) , , (..
, .).
,
.

15. XP.

(small releases)

.
(
, - ).
(metaphor)

. ,
, -
.
(simple design)
,
.
. , .
(test-driven development)
, ,
. ,
, , .
(refactoring)
,
, , ,
.
,
.
(
).
(pair programming)
.
. , ,
.
45

, , ,
, .
(collective ownership)
.
,
.
(continuous integration)
,
, ,
.
40-
.
2
.
(on-site customer)
,
.
,
, , ,
,
.

.
. ,
, . , ,
( )
.
(open workspace)
, ,

.
(just rules)
,
,
.
, XP
( 10 ), .

.
XP, , ,

,
, .

,

.
XP ,
,
XP
C3 (Chrysler Comprehensive Compensation System,
46

Daimler Chrysler). 20- 5 (


3 XP)
3 , XP.
[6,7,8].
[9],
, XP
.
1995 . 1996 , ,
XP.
. ,
. 1998
, 10000 . ,
1999
87000 . 2000
4- XP .
10000 ,
, 30000 . ,
, ,
, .

3
[1] . . . .: , 2002.
[2] . , . , . .
. .: , 2002.
[3] Kroll, The Spirit of the RUP. www-106.ibm.com/developerworks/rational/library/
content/RationalEdge/dec01/ TheSpiritoftheRUPDec01.pdf
[4] . . . .: , 2002.
[5] http://www.agilemanifesto.org/
[6] K. Beck, et. al. Chrysler goes to Extremes. Distributed Computing, 10/1998.
[7] A. Cockburn. Selecting a Projects Methodology. IEEE Software, 04/2000.
[8] L. Williams, R. R. Kessler, W. Cunningham, R. Jeffries. Strengthening the Case for Pair
Programming. IEEE Software 4/2000.
[9] G. Keefer. Extreme Programming Considered Harmful for Reliable Software Development.
AVOCA Technical Report, 2002.
http://www.avoca-vsm.com/Dateien-Download/ExtremeProgramming.pdf.

47

4.

,
, ,
.


, , ,
, , , , ,
, .



, ,
, ,
.
,
.
.
, ,
, . ,
:
, ,
, , ,
.
, ,
,
. ,
,
-,
.
, ,
, , . ,
, ,
, ,
. ,

.

,
.
, .
-,
,
.
, .
, , ,
, ,
. ,
,
48

. , -
.
, ,
( John Zachman, [1,2]) (enterprise architecture
framework).

5. . .

:
, , , , ,
, . 6 6
.
, .
, ,
.
, .

.

.
,
.
, -
.
,
, .
,
.
49

,
, , .
,
, , ,
,
,
.

.
,
.
,
, , .
, ,
.

16. -.


(data flow diagrams). 4
: ,
, ,
.
,
- (Yourdon-DeMarco, [3,4]) - (GaneSarson, [5]), 1979 . . 16 ,
, .
-: ,
, .
. 17 -:
50

, ,
.

17. -.

:
, ,
. ,
, . ,
.
, , ,
.
. 18 .

.
(entityrelationship diagrams, ER diagrams) [6],
. , .
. 19.

, , ,
-
- .
-
.

RUP ,
.
51

18. " ".


:

,
( ).

UML , , .
, .

19. .

52


,
, ,
, . , ,
,

.
.
,
.
, , ,
,
.
.
1. -- .
2. ,
, .
3. .

, . ,
, .
, Oracle ,
,
. , ,
Oracle ,
:
. :
,
.

, , .
, ,
, ,
-
, .

, .. ,
, .
,
,
, ,
.
,
.
,
, ,
,
( ).
( )
.
53

, ,
. :
.
.
10000 .
.
,
, . ,
.
,
, ,
, . ,
, . 20.
,
,


20. , , .

, - ,

. ,
, , ,
. ,
.

.
, ,
, , ,
, ,
, .

.
,
,
.
( ), IEEE.
IEEE 830-1998 Recommended Practice for Software Requirements Specifications [7]
( ).
.
54

, ,
.
o ( ).
o ( ).
o ( ,
).
o ( ).
o .
o (

).
o (
).
o ( ,
, , ,
).
IEEE 1233-1998, 2002 Guide for Developing System Requirements Specifications [8]
( ).
- .
.
o .
o .
o .
o .
o .
o , .
o .
o , .
o .
, .
o , .
o .
o .
o .
.
o .
o , .
o .
o ,
.
o ,
, .
o (.. ).
o . (
, ):
.
.
55

(reliability, , ).
(availability, ,
).
(maintainability, , ).
(performance, , ).
(accessibility, ,
).
(,
, ).
(ergonomic, , ,
).
(safety, ,
).
(security, , ).
(, ).
(transportability, , ).
(, ).
(, ).
(, ).
(, ).
(,
).
(,
).
.
.
(, ).
(, ).
(, ,
).
IEEE 1233 ,
.
o . ,
.
o ,
,
.
o , .
o ,
( , ),
,
( .. , ...).
o , ,
,
.



,
RUP.
(use case) ,
.
56

, ,
,
.
:
- .
, -
, . , ,
.

.
, , ,
,
, .
, , ,
, ,
, ,
.
, .
UML ,
.
(actors),
, .
:
(generalization), (extend relationship) (include relationship).

(generalization).

21. -.


,
, .
.
,
, ,
. ,
( )
, ,
.
A (extends) B,
A B.
57

, , ;
, ,
,
. ,
.

extend

include
include


extend

22. -.

A (includes, , uses)
B, A B. ,
. ,
.
, ,
, ,
. ,
,
, .
, . ,
.
[9].
1. , .
2. . , .
3. . .
4. . .
5. . ,
.
6. , .
7. , .
.
8. () .
9. () .
10. () .
11. () : , , ,
, .
12. () ,
.
58

,
.
,
, ,
,
, .
, .

4
[1] J. A. Zachman. A Framework for Information Systems Architecture. IBM Systems Journal,
vol. 26, no. 3, pp. 276-292, 1987.
[2] J. F. Sowa and J. A. Zachman. Extending and Formalizing the Framework for Information
Systems Architecture. IBM Systems Journal, vol. 31, no. 3, pp. 590-616, 1992.
[3] E. Yourdon. Modern Structured Analysis. Prentice Hall, 1988.
[4] T. DeMarco. Structured Analysis and System Specification. A Yourdon Book, Yourdon Inc., NY,
1979.
[5] C. Sarson, T. Gane. Structured Systems Analysis. Englewood Cliffs, NJ.: Prentice-Hall, 1979.
[6] P. Chen. The Entity-Relationship Model: Toward a Unified View of Data. ACM Transactions on
Database Systems I (I). March 1976, pp. 8-46.
[7] IEEE 830-1998. Recommended Practice for Software Requirements Specifications. New York:
IEEE, 1998.
[8] IEEE 1233-1998. Guide for Developing System Requirements Specifications. New York: IEEE,
1998.
[9] . . . .: , 2002.
[10] . . . .: , 2002.
[11] . . . . .: , 2004.
[12] . , . .
. . .: , 2002.
[13] . , . , . .
. .: , 2002.

59

5.

, ,
. ,
.


, , , , ,
, , , ,
, .



, ,
? , ,
.
,
, , ,
.
.
,
, .
.
.
.
.
.
24 7 .
.
.
.
.
, ,
. , ( ,
, , , ,
.),

, .
,
.
( , ).
, (,

), , , .
ISO 9126 [1]
,
.
ISO 9126 [1-4] .
60

,
, ; ,
; ,
.
, . ,
.
, ISO 9126, . 23.

23. ISO 9126.


ISO 9000.
.
ISO 9000:2000 Quality management systems Fundamentals and vocabulary [5].
. ( -2001).
ISO 9001:2000 Quality management systems Requirements. Models for quality assurance
in design, development, production, installation, and servicing [6].
.
, , , .

. ( -2001).
o
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
61

.
.
.
.
o ,
.
.
.
.
.
.
.
.
o ,
, ISO 9001 :
,
.
,
,
, .
, (,
) ,
.
,
, ,
.
,
.
ISO 9002:1994 Quality systems Model for quality
assurance in production, installation and servicing ISO 9003:1994 Quality systems Model for
quality assurance in final inspection and test 2000
ISO 9001.
ISO 9004:2000 Quality management systems Guidelines for performance
improvements [7].
. . (
-2001).
ISO/IEC 90003:2004 Software engineering Guidelines for the application of ISO
9001:2000 to computer software [8].
ISO 9001 ,
.
ISO 9001 ,
.
,
.
ISO 9126 [1-4]
. 6
.
. , .
ISO 9126 . 24.

62

24. ISO 9126.

ISO 9126:2001.
(functionality).
, .
, , .
o (suitability).
.
o (accuracy).
.
o (interoperability).
.
o (compliance).
,
, .
o (security).
, .. ,
, .
(reliability).
.
o , (maturity).
, .
,
.
o (fault tolerance)

.
o (recoverability).

, .
o (reliability compliance).
2001 .
63

(usability) .
,
.
o (understandability).
, ,
.
o (learnability).
, ,
.
o (operability).
, ,
.
o (attractiveness).
.
2001.
o (usability compliance).
2001.
(efficiency) .

.
.
o (time behaviour).
,
.
o (resource utilisation).

. ,
, , , .
o (efficiency compliance).
2001.
(maintainability).
, .
o (analyzability) .
, ,
.
o (changeability).
, .
o (stability).
,
.
o (testability).
,
, .
o (maintainability compliance).
2001.
(portability).
,
, .
.
mobility
64


.
o (adaptability).

, .
o (installability).
.
o (coexistence).
,
.
o (replaceability) .

.
o (portability compliance).
2001.

ISO 9126. ISO 9126-4 [4]
, .
(effectiveness).

.
(productivity).

.
(safety).

, , .
(satisfaction).

.
ISO 9126:2001
.
.

. .

. .
.
.
.
.
.
.
. .

, ,
. , .
, :
;
65

;
,
.
, :
7 24 ;
3 ;
.
, :
, ,
2 ;

80% .
, :
10000 ;
3 ;

0.1 ;
1 MB .
, :
3 -;

$20000.
, :
Linux, Windows XP MacOS X;
MS Word 97 HTML;
MS Word 2000, MS Excel 2000, HTML,
RTF ;
.
, ,
. , ISO 9126 ,
(mobility), ..
, .
(dependability),

(, , )
.
, , ,
,
.


? , ,
, ? , , ,
?
.
,
,
, .
, , .. ,
,
.
66

, ,
.
.
[9] ,
.
.
,
. ,
, , , , ,
.
.
, .
, , ,
,
, , .

.
(model checking),
(), .
,
, .
,

, ,
,
.

.
,
,
.

.

,
, .
.
. ,
, . , ,
,
. ,
. (Dijkstra) ,
, , , .
,
. ,
,
. , , A
B, , ,
A, , , B .
,
67

. , ,
. ,
, ,
.
, : ,

, ,
, .

25. .

.
, .
.
IEEE 829-1998 Standard for Software Test Documentation.
, .
IEEE 1008-1987 (R1993, R2002) Standard for Software Unit Testing.
(. ).
ISO/IEC 12119:1994 ( AS/NZS 4366:1996 -2000, IEEE
IEEE 1465-1998) Information Technology. Software packages Quality requirements
and testing.
.
,
. ISO 9126
. ,
,
, , ,
, . ,
,
,
,
, .
, ,
.
, .
,
, , .
(conformance
68

testing). ,

.

,
( ) ,
.
,
, .
, .


(, ,
).
, .
, .

, . ,
, (smoke testing),
, , ,
.

, , ,
.
, .
,
. ,
.
(unit testing)
, . ,
,
, .
,
,
, , ,
, ,
.
,
.
(integration testing)
.
,
, , ,
.
, .
(system testing)
,
.

( ),

.
69

(Graphical User Interface, GUI)


Web- (WebUI).
,

(Application Programming Interface, API),
, API
.
, ,
. ,
( )
, .
, , XP.


(model checking) [10]
,
( )
.
, .
,
.

26. .

,
. (safety properties) ,
. (liveness
properties) , ,
.
(deadlocks).
,

, ,
, ..
,
,
, ( )
( ).

.
70

- . ,
, - ,
, .

, - .

. , , ,
.
, , ,
,
, , .
, ,
.
, ,
, .

, , .


, ,

.
,
.
defect - ,
( ,
.).
failure , -
. .
fault ,
(failures), , . ,
, , ,
. ,
, ,

.
error .
,
, (faults). , , ,
.
( ),
.
.
,
, , , .
.
, .
, .

, .
71


.
.
, , ,
, .
,
, , ,
.

,
,
, ,
, .
.
, , ,
.
,
,
.
,
, ,
.

(. [11,12]) ,
-5 4 1996 (. [13]), $500 000 000.
14 2003 - ,
4 10 [14],
.
,
. , , ,
, .
, , ,
, .
.
, . ,
,
, ,
.
, (failure)
, . ,
, ,
(
).
- ,
,
.
, ,
.
, -5 [13].
-5 ,
, -4.

72

-4.
,
, , ,
,
.
.
, -4,
.
,
- ,
, ,
, .
80%.

, ,
.
,
, .
, ..
, ,
,
.
, -
, ,
, .
, .
- ,
,
.
, ,
20 .
.

5
[1] ISO/IEC 9126-1:2001. Software engineering Software product quality Part 1: Quality
model.
[2] ISO/IEC TR 9126-2:2003 Software engineering Product quality Part 2: External metrics.
[3] ISO/IEC TR 9126-3:2003 Software engineering Product quality Part 3: Internal metrics.
[4] ISO/IEC TR 9126-4:2004 Software engineering Product quality Part 4: Quality in use
metrics.
[5] ISO 9000:2000 Quality management systems Fundamentals and vocabulary.
[6] ISO 9001:2000 Quality management systems Requirements.
[7] ISO 9004:2000 Quality management systems Guidelines for performance improvements.
[8] ISO/IEC 90003:2004 Software engineering Guidelines for the application of ISO 9001:2000 to
computer software.
[9] . . . . .:
, 2003.
[10] . . , . , . . : Model Checking. .:
, 2002.
[11] http://www5.in.tum.de/~huckle/bugse.html
[12] http://infotech.fanshawec.on.ca/gsantor/Computing/FamousBugs.htm
[13] http://www.ima.umn.edu/~arnold/disasters/ariane5rep.html
73

[14] http://www.elcon.org/Documents/EconomicImpactsOfAugust2003Blackout.pdf
[15] . . . .: , 2002.
[16] . . . . .: , 2004.
[17] . , . , . . .
.: , 1991.

74

6.

, ,
.
UML.


, , , ,
, , ,
, , .



, , ,
, , ,
. ?
( , , )
, .

, . , , , , ,
.
, , .
,
, , ,
,
, .. -
,
. ,
,
.
, , ,
.
( ,
- ),
,
, .

, .


,
,
, [1].

, ,
, . (.
) ,
, ,
.
75

, . ,
, , .
UML ,
, .
, . ,
,
, .

,
,
, ,
.
.
, (- ,
, , , ., ),
,
.
,
( , , ..
, .),
.
.

.
. ,
, ,
, , ..
:
,
.
o , , .
o ,
.
o .
o , .
o ,
.
o
, .
o ,
.
o , , ,
, .
,
. , , ,
,
(
-
). ,

.
76

, ,

, . ,
,
,

.
,
.
, .
.
, ,
,
.
,
. ,
.
,
.
, ,
,
, .
.

27. .

. 27 .
, .
.
. ,
.
.
,
, .
77

.
,
.
, , ,
.
,
.


.

, .
,
, (
). ,
, , ,

.
, , ,
,
, . ,
, ,
, ,
.
,
, , ..
. , ,
. , ,

.

.

. , ,
. . ,
.
,
, ,
.
, ,
, .
IEEE 1016-1998 Recommended Practice for Software Design Descriptions [2]
( ).
IEEE 1471-2000 Recommended Practice for Architectural Description of Software-Intensive
Systems [3] ( ).
,
.
, ,
, ,
,
.
, ,
78

, .
IEEE 1471 (architectural
description) ,
.
,
.

, , , ,
,
,
,
.
IEEE 1471
, .
o .
o , .
o ,
, , ,
.
o .
o ,
.
o .
o , ,
.
o ,
, .
o , .


,
, .
1.
a.
.
b. , (.
)
,
, .. .
c.
.
d.
, .
2.
a. ,
.
b. ,
, ,
.
c. , .
79

d. ,
, .
3.
a. ,
, .
b. , ,
.
4. .
, :
a.
.
b. ,

.
c.
, .


.
(Software Architecture Analysis Method, SAAM) [1,4]. .
1. ,
,
. ,
, , ,
. ,
. ,
.
2. ( ).
, .
3. . ,

. , ..
, ,

. , ,
, ,
.
4. . ,
.
,
, .
, .
5. .
;
.
.
,
, ,
.
, (> 2-) ,
.
80

6. ( ).
.

, ..
.






.

, , ,
, , , ,
, , ,
, ,
, , ,
, , ,

28. .

1. .
a. , ,
.
b. , , , ,
, .
c. , ,
.
d. ,
,
.
2. .
a. .
,
, .
, .
(. ).

29. .

b. .
,
. ,
. , ,
( , ) ,
,
(,
).
.
i.
.
(, , ),
.
.
.
81

ii.


, ;
, .
iii. ,
, ,
.
iv. .
(. ).

30. .

3. .
a. a.
.
, ,
,
,
, .
b. b.
.
,
, ,
.

, ,
(,
) ,
.
c. c.
.

, , .
d. d.
.
,
-

.
, , ,
.
4. .
6.
5. ,
.
82

, .
,
, , .

a
-++++

b
++*
++-+*

c
++*
++++*

d
++*
++-+*

6. .
+ , - ,
*

6. .

. ,
, ,

.
, , .
-
. ,
,
,
.

UML. UML
, ,
.
(Unified Modeling
Language, UML) [5-7],
, ,
.
UML 8 . 9- UML
, (. 4),
. ,
,
. UML
, ,
, .
UML .



, , ,
- .
. , ,
.
(class diagrams) ,
( ) .
. 31.
, .
, , , ,
(public +, protected #, private -) ,
.
83

.
. 31 Account, Person, Organization, Address, CreditAccount
Client.
CreditAccount private maximumCredit double, public
getCredit() protected setCredit().
, .. ,
, ,
. . 31 AccountInterface.

31. .

,
, .
, A
B, ( B,
A, A)
(
).
. 31 Organization Address.
( ) , A
( ) B,
B A.
, , A
B. .
, ,
, . . 31
Account Client.
, ,
B A.
,
, n.
84

. . 31 ,
Account Client, ,
, ,
.
,
. . 31 CreditAccount Account,
Person Organization Client.
,
,
. ,
(
). . 31 Account
AccountInterface.
,
.
. Person
AddressKind . 31.
, (map)
,
, , .
,
.
. 31 Person Address, ,
Person kind, ..
.
.
(object diagrams)
, .
(
, ) .

.
.

32. .

(component diagrams)
,
.
,
, HTML- .,
JavaBeans, CORBA, COM ..
. 12.
85


.
, ,
. ,
.
.
.

33. .

, . 33, ,
,
.
UML , .

.
.
(deployment diagrams)
, , ,
, . ,
.
, (nodes),
, .
(
)
, , EJB AccountEJB
, AccountInfoEditor .

34. .

86

.
. 34.


.
, , .
(activity diagrams) ,
.
,
, .
.
(forks) (joins) (-
),
. ,
,
.
.

, (swimlanes).
, ,
, .

(. 4), .
. 35.

35. .

( , sequence diagrams)

( ,
,
, .).
(Message
Sequence Charts, MSC), UML
.
87

, ,
. ,
. , . ,
, .. ,
,
.

aClient : Client

AccountManager

anAccount : Account

new Client()
createAccount (aClient)
addAccount()
new Account()

deposit()

36. .

-
-. ,
.
, , ,
. . 36.
(collaboration diagrams) ,
, / ,
. . 37.
aClient : Client
1. new Client()
2.1.1. new Account()
3. deposit()

anAccount : Account
2.1. addAccount()

2. createAccount (aClient)

AccountManager
37. , . 36.

.
, ,
.
. ,
(.. 1, ,
, 1.1, 1.2, ..).
.
88

(statechart diagrams)
, -
.
,
. ,
.
. 35
: ,
, .
. 38.
:
,
. , .
. 38 Site.
, , ,
cancel
Basket.

38. , -.

.
, ,
.
89

,
.

( ) , - .
.
. 38 ,
items, , , basket.
,
, ,
, , .
:
o , .
,
.
, Categories . 38 ,
. back,
Start page. Categories
.
. choose(category).
o ( , guardian). ,
,
.
, .
.
. 38 Basket
Payment Method. ,
( buy) .
o , .
- .
( /).
, , ^,
.
, . 38
Categories Items list. ,
, .
, ,
.

6
[1] . , . , . . .
.: , 2006.
[2] IEEE Std 1016-1998 Recommended Practice for Software Design Descriptions.
[3] IEEE 1471-2000 Recommended Practice for Architectural Description of Software-Intensive
Systems.
[4] R. Kazman et al. SAAM: A Method for Analyzing the Properties of Software Architectures.
Proceedings of the 16-th International Conference on Software Engineering, 1994.
[5] . , . , . . UML. . .: , 2000.
[6] . , . , . . UML: . .: , 2002.
[7] . , . . UML . .: , 1999.
[8] . . . .: , 2002.
[9] . . . . .: , 2004.
90

7.

,
.


, , , , ,
, ,
.




? ,
, ,
, .
,
, , ,
,
.

.

XX (design patterns
patterns), .
,
. ,
, , [1].

,
,
, .
, ,
90- , , ,
,
, . , ,
,
, .
, , ,
.
(pattern) ,
, ..
.
.
. ,
. - , ,
(
, , ,
,
). ,
91

.
!
.
,
, .
, , , ,
. ,
.

- ,
(adapter).
Client

TargetInterface
+ operation1(Param1)
+ operation2(Param2)
+ operation3()

Adapter

Implementation

+ operation1(Param1)
+ operation2(Param2)
+ operation3()

+ implOp1(ImplPar1)
+ implOp2(ImplPar2)
+ implOp3()

39. - .

. ,
, ,
( ), ,
.
, - (
), ,
.
(, , ),
.
.
,
, (
, ) , .
,
. ,
(pattern system) (pattern
language), ,
.
.
(analysis patterns).

.
,
- .

92

,
,

,
. , , ,
, , .
,
,
.
(. ),

. , X
,
getX() setX() getX() (.. , property, C#
JavaBeans).
(architectural styles, architectural
patterns).

,
.
(design patterns) .

, .
(idioms, programming patterns).

, , ,
.
(organizational patterns) (process patterns).

,
, .
.
,
. .
, , .
, .
, .
, ,
.
. .
o , ,
. ,
.
o .
o ,
(
Java). .
o ,
, .
93

.
, .

.
, Java C#.



.
(Martin Fowler) [2,3].
,
.
(quantity).
, ,
( 182, 83), .
, , ,
, ,
. 1998
Mars Climate Orbiter,
. ,
, .

,
. ,
, , 130
[4].

Quantity, ,
. , ,
.
Quantity
+ amount : Number
+ units : Unit
+, -, <, >, ==

40. , .

,
. .
,
. . ,
,
, , ,
.
,
.
, ,
, .

94

Quantity
+ amount : Number
+ units : Unit

+ to

Unit

Conversion

+ from

+, -, <, >, ==

Ratio

+ convert()

0..1

+ ratio : Number

41. .


, (1 = 1 */2).
, Unit
, PrimeUnit, , CompoundUnit,
,
, , , .
Unit

PrimeUnit
0..*

+ direct
0..*
+ inverse

CompoundUnit

42. .

, ,
, . , ,
, , , . ,
(,
), . .
,
, .
Object

0..*

Measurement

Quantity

0..*
1
Phenomenon
Type

43. .

, , ,
, ,
( II, 3- .).
:
- .

, . 44.
, - . ,
, II , ,
. , ,
, .
95

Object

Observation

0..*

Category
Observation

0..*

Measurement

1
Phenomenon

0..*
1

Phenomenon
Type

Quantity

44. , .



.

,
, .
, .

1990- . [5,6].
, .

(data
flow)



,
,
,
. (
)
-,

.


.

(batch
sequential)

-

,
.


: ,
,
,
.

(pipe-andfilter)


.

. , ,
.

.

UNIX

96

(closed-loop
control)

-
(call-return)



.
,


,
.



, ,
.


Web-.

GUI.

,

,
.

,
, .
,

.



C, Pascal,
Ada


(abstract data
types)

,
.
.
,

.
.


(layers)


,

, , ,
, ..

.

,

.
, ,


.


OSI (7 ),


( 5
).

).


,

.


-:


,

.
97


,
.

(model-viewcontroller,
MVC)


,
- ,

.
,
, ,
,
, ,

.

(presentationabstractioncontrol)

,

,
.
,
,

,
.


.

(repository)

GUI.
Document-View MFC
(Microsoft Foundation
Classes)


.


,
.

.

.
-
.


CASE-

(blackboard)
, ,
,
,

.
,
.

.
,
.
7. .

98


. , ,
, ,
,
.
,
. [7].


. (pipes and filters).
. ,
.
, ,
. .
.

,
.
.
.
,
, , .
.
,
, ,
.
.
.
. .
(filter).
, .
(pipes).
.
. (data source)
(data sink), , ,
.
, .
,
, - .
,
, ,
. .
,
(, ,
).
,
.

99

45. .

. 45 , 3
, .
, Filter 1
, Filter 3 , Filter 2 ,
.
Filter 1

Filter 2
send data

Filter 3

process data
send data

46. .

Filter 1

Filter 2

get data

Filter 3
get data

process data

47. .

.
(push model, ,
), (pull model,
,
100

) .
. ,
.
.
Filter 1

Pipe
process data

Filter 2
read data

write data
process data
write data

process data
read data

48. .

. .
, .

.
.
,
, .
. ,
.
.
,
. , , ,
.
.

,
, , .
,
.
.
.
, ,
- .
, , ,
,
.
,
.
,
.
101

.
,
, .

,
, ,
-,
.

, . , ,
, .
. ,
,
,
, .
.
UNIX [8], (shell)
.
,
.

,
(), (),
, .
.
, ,
, , .


. (layers).
. ,
, .
,
(..
, ,
).
.
.

, ,
. ,
.

.
.
, .
,
.

.
102


.
:
, .
.

,
.

. ,
, .
. ,
. ,
, , ,
.

.
. . ,
.
. ,
.
.

49. . ,
.

.
. ,

( - )
.

.
(,
) , ,
, .
, ,
, . , , ,

.
103

,
. , (
- ),
. , Capslock
,
, .
Client

Layer 2

send
message

send
packet
send
packet

Layer 1

send raw
data
send raw
data

Layer 1

Layer 2

Client

receive
packet
receive
packet

receive
message

50. .

. .
. .
, ,
.
, , .
,
. ,
, .
,
,
.
, .
, ,
,
.
.
.
, .
.
,
.
(callbacks) ,
,
.
.
, .
.
.
,
.
.
104

.
, POSIX.
.

.

.
-
.
, , ,

.

. ,
(, )
.
.
(Open System Interconnection, OSI) [9].
7- .
.
.
, (
),
, ..
.
,
.
.
, ,
,
.
.

, . ,
,
.
,
( ),
, .
, , .
, , 4-
, ,
,
(.. 0x0000000f 15, 0x80000000f
-2147483633 = -(231-15)).
, ,

HTTP, FTP, SMTP, POP3 .
OSI .
OSI
105

,
.

.
[3].
.
.

, , ,
.
-.
, .
. ,
.
.
.
, ,
. ,
.
, ,

.
,
,
.

,
.

7
[1] . , . , . , . . -
. . .: -, 2001.
[2] M. Fowler. Analysis Patterns: Reusable Object Models. Addison-Wesley, 1997.
[3] . . . .: ,
2004.
[4] Mars Climate Orbiter Mishap Investigation Board Phase I Report.
ftp://ftp.hq.nasa.gov/pub/pao/reports/1999/MCO_report.pdf
[5] M. Shaw and D. Garlan. Software Architecture: Perspectives on an Emerging Discipline. Prentice
Hall, Englewood Cliffs, NJ, 1996.
[6] M. Shaw and P. Clementz. A Field Guide to Boxology: Preliminary Classification of Architectural
Styles for Software Systems. Proceeding of COMPSAC, Washington, D.C., August 1997.
[7] F. Buschmann, R. Meunier, H. Rohnert, P. Sommerlad, M. Stal. Pattern-Oriented Software
Architecture. A System of Patterns. Wiley, 2002.
[8] . . . 2- . .: , 2002.
[9] . . . 4- . .: , 2003.
[10] . , . , . . .
.: , 2006.
[11] . . . . .: , 2004.

106

8. ()

:
, , .


, , , , ,
--, ,
, .



, ,
: ,
.

. (modelviewcontroller, MVC).
. .
.
.
, ,
,
- ,
. ,
.

.
.
.
-
,
.

.

,
.

,
.
. . ,
(model) ,
. :
. (view)

. .
,
(controller) , .
,
107

, ,
. .
,
.
. ,
.
- ,
.
.
observers

Observer

0..*

Model

model

data

update ()

View

attach (Observer)
detach (Observer)
notify ()

initialize (Model)
makeController ()
activate ()
display ()
update ()

getData ()

view

Controller

controller

initialize (Model, View)


handleEvent ()
update ()

model

51. , .

- ,
, ..
. , .
- ,
.
,
, - .
Controller

Model

View

handle event
change data
notify
update
get data
display

get data

update

52. .

.

.
108

Program

Model

View

Controller

create
create
initialize (model)
attach

makeController
create
initialize
(model, view)

attach

53. .

. .
.
, ,
.
.
( , Observer).
.
.
.
.
, ,
(Factory Method).
.
.
, .
,
. ,
.
.
,
.

.
, ,
, .
, ,
.
( ,
)
, ,
, .
,
.
.
109

.
.
,
.
, .

.
.
( )
.
.
.
-
, ,
.
,
,
.
, -
.
,
.


.
GUI,

, ,
.
.
Smalltalk [1].
.
,
MFC (Microsoft Foundation Classes) Microsoft.

. - (Document-View):
,
.
,
.
.
Web, .. - HTML
,
. , -
, HTML- HTML, .
, - .
110


,


.
. ,
, .

. (subscriber) - (publisher-subscriber).
(observer), (listener)
(dependents).
. ,
.
. ,
, ,
, .
, .
(
) ,
. .
.

.
,
,
.

.
( )
.
. , , .
-,
, .

update().
Publisher

observers
0..*

attach (Subscriber)
detach (Subscriber)
notify ()
getState ()
publisher

Subscriber
update ()

forall o in observers
{ o.update(); }
ConcreteSubscriber
update ()

54. .

. ( )
( ). ,
111

update() ,

. ,
.
update().
. :
, ( , push
model), ,
, ( , pull model).
, ,

.
Publlisher
change

Subscriber 1

Subscriber 2

notify
update
get state

update
get state

55. .

. .

update()
- .
:
.
. ,
,

, .

.
-
, .
, ,
, , ,
, ,
(change manager).
,

. ,
,
, .
112

,
.
, ,
.


,
.
-
, , .
, ,
. ,

, ,
.
. -
-.

(Event Channel)
CORBA [2].

,
. ,
.
. ,

, .

JavaBeans, C# .
[3].


. (template method).
. , ,

, .
.
.
,
.
,
,
.

, ,
( ).
113

. , ,
, . ,
- ,
, .
. , ,
.
. , , .
,
.
, .
-
, .
-, (hook operations),
,
, .
-,
.
(factory methods), ,
. ,
. ,
,
.
. . 56.
, ,
: ,
, , ,
() .
Abstract Class Methods
method()

Concrete Class Methods

concrete operation
abstract operation 1
default hook operation
abstract operation 2
overriden hook operation

56. .

. .
. ,
.
, .
.
114

, , ,
.
, .
,
, , ,
.
.
,
, .
,
. -.
.
,
, , ,
, -.
.

.
,
.
,
.

.
,
.
.
.
EJB ,
.
-,
.
start(), Java.
, , run()
Thread , Runnable. start() run()
.



, .
, ( ).
,
.
,
- .
. , ,
,
.
.
115

.
, .
, , , ,
.
, ,
, .
,
, .
(Fagan
inspection process), (Michael Fagan) [4,5] ( ,
, technical review, [6]).


. (Fagan inspection process).
.
, ,
, .
.
, , , ,
, .
,
( )

3-5 .
, .
, ,
.
,
.
.
, , ,
,
.
,
,
.
.
.
, .
,
, 8.
.
(moderator). , ,
, ,
, .

, , .
(author). ,
.
116

,
.
(reader). ,
.
, ,
.
(tester). ,
.

,
,

8. .

4- ,
. ,

.
.
1. (planning).
,
, ,
.
,
, , ,
.
2. (review).
,
.

.
, ,
, ,
,
.
3. (preparation).
,
.
, , .
4. (inspection meeting).
,
, , ,

.
117

.
( - ),
, ,
, .. .
, ,
, , ( )
( ,
.).
5. (rework).
.
6. (follow-up).
. ,
.
5% ,
. ,
.
,

.
.
,
, .
,
.
,
,
,
,
.

. , 80% ,
.

8
[1] G. E. Krasner, S. T. Pope. A cookbook for using the Model-View-Controller user interface
paradigm in Smalltalk-80. Journal of Object-Oriented Programming, 1(3), pp. 2649, AugustSeptember 1988. SIGS Publications, NY, USA, 1988.
[2] CORBA Event Service Specification, version 1.2. Object Management Group, October 2004.
http://www.omg.org/cgi-bin/apps/doc?formal/04-10-02.pdf.
[3] . , . , . , . . -
. . .: -, 2001.
[4] M. E. Fagan. Design and Code inspections to reduce errors in program development. IBM
Systems Journal, vol. 15, No. 3, pp. 258287, 1976.
[5] M. E. Fagan. Advances in Software Inspections. IEEE Transactions on Software Engineering,
vol. 12, No. 7, pp. 744751, July 1986.
[6] S. Ambler. Process Patterns: Building Large-Scale Systems using Object Technology. Cambridge
University Press, Cambridge, MA, 1998.
[7] . . . .: ,
2004.
[8] F. Buschmann, R. Meunier, H. Rohnert, P. Sommerlad, M. Stal. Pattern-Oriented Software
Architecture. A System of Patterns. Wiley, 2002.
[9] . . . . .: , 2004.
118

9.

, -
, .
, .


, , , , ,
, , ,
, , ,
, GOMS, .




. ,
, ,
, ,
.
, ,
.
,
.
.
, .
,
,
.
,
.
,
.
, ,
. RTFM! (read this fucking manual,
). ,
, .
, ,
(
).
, , Microsoft Word, - ,
.
, ( !),
. ? ? ? ?
, . ? , , , ,
. -, 10 , ,
( ?...). , .
,
.
119

(
WYSIWYG), . ,
,
. ,
, , , .
, - (, , ,
) . , ,
.
. ,
, .
, .
, .
.
,
.
- , ,
, . , ,
, .
,
, .
, ,
, .

,
.
( , -
, ),
, .
,
?
, ,
. ,
, ,
, -
. ,
. ( , ), ,
.
, ,
, , ,
, ,
- . ...
, ,
Palm Pilot, ,
2-
.
,
- , ,
,
.
,
, ,
.
120

57. ? ,
Windows? , ?



, .
, ,
, .

, -
, - ,
.


, .
, ,
[1,2].
, ,
,
(Human-Computer Interaction, HCI).

.
.


.
, , ,

,
, .

, .
, ,
, .
,
,
, , . , ,
, , .

, , ,
,
.
, , ,
, .
, ,
, ,
, .
121

, , , ,
.
, , - ,
: !
!, .
, , , , ,
,
. ,
, .

58. 11,3 ?

, , ,

.

, , , .
,
. .


, ,
, [3,4].
: 0.21.25 .
: 0.1 .
(. ): 1.0-1.5 .
,
, , .
: 0.1 .
: 0.25 .
( ): 1.25 .
: 0.36 .
GOMS
(. ).
[5],
, ,
, , ,
,
.
, ,
, .
.
122

,
.
,
,
.
-,
.
, ,
, ,
.
, , , .
, . -
, .

(Fitts) [6] T = a + blog(D/W) ( a + b(D/W)).
D , , W , a b
, . ,
, .
,
. ,
, , ,
, ,
.

59. MacOS () , Windows (),


.
, , .

,
, .
, , ,
. , Windows
123

, , -
, ,
, .


-
. , ,
, - .
, .
, ,
. ,
,
,
. -
(, .),
,
, .

,
, ,
, .
, , , ,
, ,
. - .
-
: , , .
, ,
.
, .
,
.
,
:
, ,
. ,
!
, , -,
.
, ,
. ,
, , , ,
, , . ,
, , .
, , ,
( ),
.
,

.

124


-,
. , , [4].
1. . ,
. , ,
, ,
.
, - ,

,
.
, ,
, ,
, .
, ,
, .
2. . , ,
, .. -
( ), , ,
. ,
, .
Windows.
,
.

Windows
, .
,
.
.
, ,
.
, .
3. (affordance). ,
, ,
( !)
.
:
a. !.
,
.
b.
, ( ),
,
.
, , ,
, .
, ,
, , ,
, . .
, , (,
125

, , ),
, .

60. . "" Next .

4. . , .

.

.
,
. ,
, .
,
,
. , , -,
, -, ,
. ,
, ,
,
.
,
.


.
, 5-9 (72) .

; , ,
.
, 7 , 10
. . ,
, 5 6 7 . ,
, .

, ,
, ,
. ( ,
), .
, 7, 5, 6
, ,
( ) , ,
, 5-, .
,
.
126

, ,
. -
. ,
- ,

, .

. , ,
, .
. ,
,
.


.
,
, 40. -
(
10% ).
,
, ,
.
,
, .
, Windows
, .
,
.
.
, ,
, , ,
.


,
, .
.

, .
: -,
( ), -,
, , .
.
,
.
.
,
.
,
,
.
127

.
,

.
, ,
, ,
, .
,
, .
, .
,
; ,
.
,
, , -
, , .
.
,
, ,
- ( 5- 7-- ).
.
,
, ,
. [4],
.
o , ..
(1:1.618)
, ,
, , ,
.
o ,
, .
- ,
.
o , ,
. .

, .
, -
, ,
.
,
, (
).
.
, . ,
(
) , .

- , .
, .
128

o ,
, ,
, .

, , ,
. [3].
.
, ,
, ,
.
, ,
. , ,
, .
.
,
.

, , (wizards),
,
- , , ,
.
.
,
.

,
.
,
.
: , ,
, , ,

.
,
,
,
. ,
.

.
.
.
, ,
. , , ,
.
.
, .
,
, .
, ,
, , .
129

,
. ,
.
,
.

.
.
, ,
; , .
.
.
.
.
, ,
, .
.

. , ,
, .
.
.

.
, ( ),
.
.
,

.



, (usage-centered design),
. . (L. Constantine, L. Lockwood) [3].
,
, ,
, .
, ,
, .
.
.
.
( ,
) - ,
, , .
, ,
.
.
o ( , .),
, , .
130

o .
o
, , , , ,
, , ,
( , ).
o , ,

o
( , , .).
o , ,
.
o , ,
.
. 61.

61. .

.

(essential use cases).
,
, .



PIN

PIN
PIN


131


9. () () .


,
.
( , )
.

9.

, .

.

.
.

( ,
, , , .)
.
, (
), , .
(
!) ,
.

.
,
,
.


(
, , ,
, )


(,
, ,
)

(
,

)


(,
, ,

)

62. .

132



( ).
.
, ,
, .
, , ,
.
. 62
, .

,
.
.

63. Microsoft Word.


.
,
.
, .
.

.

.
, ,
.
,
.
.
.
.
133

( ).
.
.
.
.
.
.
.
.
*

64. .
, , .

.
, . 64.



.
[7]
.

, ,
.

, . 3-
5-. .
,
, .
. ,
.
1-3 , ,
.
134


(, , , , , ),
( 3-4- ).
, ,
( ,
).

.
,
,
.
EE =


100%


, .
o .
o , ( )
.
o .
o ( ) - ,
.
o .
, ,

.

EE = pi * EEi
i


. .
o .
o ,
.
o : ,

, 1, 1.
o
, .. n(n-1)/2, n
.
-100% ( ) 0%
( ) 100% ( ).

, , ,
, GOMS
(Goals, Operators, Methods, and Selection Rules) [8,9].

. ,
, ,
, Web-.
135

GOMS
.
.
, 0.28 .
, 0.1 .
, 1.1 .
, 0.4 .
, 1.2 .
,
.
, ,
0.1 .

, .

, , ,
, ,
.
,
. , ,
, , .
, ,
.
, .
,
. , ,
, -, , ,
( , ,
, , -
, , ).
, , ,
,
. ,
,
.
, ,
,
. -
, , ,
[3,4,7,10-13].

9
[1] . , . .
-. .: , 1968.
[2] . . . .
http://psy.msu.ru/science/public/strelkov/index.html.
[3] . , . . . .: , 2004.
[4] . . . .
http://www.uibook1.ru.
[5] D. O. Norman. The Design of Everyday Things. Basic Books, NY, 1988.
136

[6] P. M. Fitts. The Information Capacity of the Human Motor System in Controlling Amplitude of
Movement. Experimental Psychology, 47, pp. 381391, 1954.
[7] J. Nielsen. Usability Engineering. Academic Press, Boston, 1993.
[8] S. K. Card, T. P. Moran, and A. Newell. The Psychology of Human-Computer Interaction.
Hillside, NJ: Lawrence Erlbaum, 1983.
[9] B. E. John, D. E. Kieras. The GOMS Family of Analysis Techniques: Tools for Design and
Evaluation. CMU Technical Report, 1994.
ftp://www.eecs.umich.edu/people/kieras/GOMS/John-Kieras-TR94.pdf.
[10] . . .
. .: , 2002.
[11] . . . .: -, 2004.
[12] . . -: . .: -, 2001.
[13] . , . . Web-.
50 . .: , 2002.

137

10. Java C#

Java .NET Java


#. , , ,
.


Java, .NET, J2SE, J2EE, C#, Unicode, , , , ,
, , , , , , ,
, .


Java .NET

Java .NET.
,
. Web, .. ,
,
Web
.
Java , ,

Java. Java Sun
Microsystems, Java,
IBM, Intel, Oracle, Hewlett-Packard, SAP, Bea .
.
Java Platform Standard Edition (J2SE) [1].
, , .
Java Platform Enterprise Edition (J2EE) [2].
Web- .
Java Platform Micro Edition (J2ME) [3].
,
, ,
.
Java Card [4].
, .
, , .
C , J2ME J2SE, ,
, J2EE. Java Card , ,
, (
) Java.
Java - ,
- , -,
, Java (Java Virtual Machine, JVM).
Java-
, JVM,
.
138

,
, , (,
.) , ,
.
( , , )
, , - .

, - .
JVM (just-in-time-compilation,
JIT), - -,
.
J2EE J2SE,
Web-. ,
J2ME Java Card, [3] [4].
.NET [5] , ,
.NET
. .NET
(Intermediate Language, IL, MSIL, Microsoft IL),
.NET , (Common
Language Runtime, CLR), (.NET Framework class library),
.NET .
,
. .NET ,
Visual Basic.NET, ++, C#, Java
( Java .NET J#, Java,
.NET, JVM) .
,
, ,
(Common Language Specifications, CLS), ,
.NET
. C#
.NET.
Java , .NET
, (JIT).
Microsoft .NET ,
( , ),
.
.NET (,
Mono [6]), ,
Microsoft , .NET Microsoft
.
Java .NET,
, .
Java Java,
.NET C#.
Java.
2004 1.5,
5 J2SE Java. 1.4 1.5
Java (
2005 ).
J2EE 1.5,
.
139

C# 2.0, 2005
.
Java 5 C# 2.0. ,
.
Java C#,
,
.
, .
(
) [7] [8] (
,
C# 2.0 [8], [9]).
-
,
. , .
, C#
,
C# C# .

.
1.
2.
3.
4.
5.
6.
Java C# , .

Java.


C#.

, C# Java,
Unicode,
16- . Unicode [10]
, U+10000 U+10FFFF (.. 216
220+216-1), UTF-16, .. 16- ,
U+D800U+DBFF, U+DC00U+DFFF.
( ,
), , ( ),
, , , .
,
// , ,
/* */.
(, Unicode,
_) .
\uxxxx, x 0-9, a-f A-F,
Unicode c xxxx. ,
, myIdentifier123, _, 765 (
Unicode). ( Unicode140

C#), ,
.
Java
.

@,
C# ,

.
.NET,
,

@class, @int, @public .
, @
,
.
,
,
Unicode
ASCII.
, C#
,

. add, alias, get, global, partial,
remove, set, value, where, yield.

null ,
true false, , ,
.
, , ,
( ). , ,
'a', '#', ''. ,
ESC-,
'\'' ( ), '\\' ( ), '\"' ( ), '\n' (
), '\r' ( ), '\t' ().
Unicode-, ,
, \u000a, ,
,
, .
Java
ESC-
'\010', '\142',
'\377'.

U+0000U+00FF.

C#
ESC-

.
Unicode-
.

(
) . ESC, .
, +. "Hello, world" "Hello,"
+ " world" .
C#
(verbatim string literals),
ESC- Unicode141


.
@.
, ".
,
.
, "Hello \t world"
@"Hello \t world", "\"" @"""".
, ,
1234, -7654. ,
0x 0X. int.
, long, l
L.
Java
,
0.

C#, Java,
uint ulong.
u U,
u/U l/L,
.

, ,
(3.1415926) (314.15926e-2 0.31415926e1).
double, d D. float
f F.
Java

.
0x 0X,

p P.

C# decimal

.
m M.

:
(
=
==
&&

)
<
<=
||

{
>
>=
++

}
!
!=
--

Java:
>>>

>>>=

[
+
+=
<<

]
-=
>>

;
*
*=
<<=

,
/
/=
>>=

.
%
%=

:
&
&=

?
|
|=

~
^
^=

C#:
->

::

??

C#,
,
,
.
,
# ,
.
#define #undef ,

(
,
true false).
#if, #elif, #else #endif
142

,


. ,
#if #elif,
,
true false
&&, ||, ==, !=.

using System;
#define Debug
public class Assert
{
public void Assert (bool x)
{
#if Debug
if(!x) throw
new Exception("Assert failed");
#endif
}
}

#error #warning

,
.
,
.
#line

.
,
default.
, ,
,
,

,
,
.
#pragma warning,
C# 2.0,

.
#pragma warning disable n_1, , n_k
#pragma warning restore n_1, , n_k

n_1, , n_k /
.



, , .
.
143

( ).
,
.

, Java
(packages), C# (namespaces).
, .
, ,
, .
,
. .
Java
.java.

,
package
mypackage;

C#
.cs.

namespace mynamespace {
.
, ,
. ,
,

.

.

.
namespace A.B { }
namespace A
{
namespace B { }
}


(public)
(..
),
.

.

.


,
,
.

,
, ,
.


,
( C# 2.0),
partial
, ,
.
,
,
,
.

import java.util.ArrayList;

using System.Collections;


ArrayList


(
144

.

import java.util.*;


java.util .

import static java.lang.Math.cos;

( Java 5)
cos()
java.lang.Math ,
.

)
System.Collections

,
,

.
(
)
. ,
using Z=System.Collections.ArrayList;


System.Collections.ArrayList Z.

import java.lang.*;

, java.lang
(,
,


).

.

,
-sourcepath
.

.

, ,
,

(
).

.class,
.
, ,
,
( )
.
,
,
-d.

, ,
.class ,
classpath.

.jar,


,


.

C#
(
.dll Windows)
(.exe),
.
(assembly).
,

.dll,
.

145

.class
.

public static void main (String[])

public static void Main ()

.
,
.
, main()
,

(
).

.
string[]
(
, Java) /
int.
,
,

.
Main()
.

,
(0! = 1, n! = 12n),
.
.
Java, C#
. , Microsoft
Visual Studio 2005 Beta 2. , , ,
$path %PATH%,
, .
Java Java- bin ,
Java Development Kit. C#
Microsoft.NET\Framework\v<
.NET> Windows ( Windows WINNT).
using System;
public class Counter
{
public int factorial(int n)
{
if(n == 0) return 1;
else if(n > 0)
return n * factorial(n - 1);
else
throw new IllegalArgumentException(
"Argument should be >= 0, " +
"current value n = " + n);
}
public static void main(String[] args)
{
int n = 2;
if(args.length > 0)
{
try
{
n = Integer.parseInt(args[0]);
}
catch(NumberFormatException e)
{
n = 2;
}
}

public class Counter


{
public int Factorial(int n)
{
if (n == 0) return 1;
else if (n > 0)
return n * Factorial(n - 1);
else
throw new ArgumentException(
"Argument should be >= 0, " +
"current value n = " + n);
}
public static void Main(string[] args)
{
int n = 2;
if (args.Length > 0)
{
try
{
n = Int32.Parse(args[0]);
}
catch (Exception)
{
n = 2;
}
}

146

if(n < 0) n = 2;
Counter f = new Counter();
System.out.println(f.factorial(n));
}

if (n < 0) n = 2;
Counter f = new Counter();
Console.WriteLine(f.Factorial(n));

javac Counter.java

csc.exe Counter.cs

java Counter 5

Counter.exe 5

120

120


.
,
, ,
. ,
, ,
.
, ,
: , .
Java
,
,
java.lang.Object.

,
.



(autoboxing auto-unboxing, Java 5),


. .

.

C#

.
.
, ,
System.Object,
object.

-.
,

.
object

, ,
.
, ,
2.Equals(3) (-175).ToString().


Java boolean, java.lang.Boolean.
C# bool, System.Boolean.
, true false.
.
.

== != .

! .

147

&& || () ( ).

, ,
, .., false,
true. ?:
: (x && y) ((x)?(y): false), (x || y) ((x)? true :(y)).
, a?x:y a,
true, x,
y.

& | () ( ).

^ 2.

&, |, ^ &=, |=, ^=.


x op= y, op &, |, ^, ,
x = ((x) op (y)), , x
.


.
, Java byte, C# sbyte.
-27 (27-1) (.. -128 127)
short, -215 (215-1) (-32768 32767)
31

int, -2

long, -2

(231-1) (-2147483648 2147483647)

63

(263-1) (-9223372036854775808

9223372036854775807)

-
:

C#
:
byte 0 (28-1 =
255).
16
ushort 0 (2 -1) = 65535
32
uint 0 (2 -1) = 4294967295
64
ulong 0 (2 -1) =
18446744073709551615
-
:

java.lang.Byte
java.lang.Short
java.lang.Integer
java.lang.Long

System.SByte
System.Byte
System.Int16
System.UInt16
System.Int32
System.UInt32
System.Int64
System.UInt64


(static final )
MIN_VALUE MAX_VALUE.


MinValue MaxValue.

==, != .

148

<, <=, >, >= .

+, -, *, /, % , , , ,

++, -- .
, ,
.

x = 1; y = ++x; z = x++;

x 3, y z 2.

~, &, |, ^ , ,
.

<<, >> ,
, .

Java >> ,


.
>>>

.

C# >> ,

,
.

+, -, *, /, %, ~, &, |, ^, <<, >> ( Java- >>>)


. x op= y, op
, x = (T)((x) op (y)), T x,
, x .

Java

, ,
.
,
2n n,
.


: 0
0,

, null,
Java- ,
- -- ++
.

C#
,
, ,
.
unchecked
(.. ,
unchecked),

2n.
checked
(.. ,
checked),

.
,
, unchecked ,
,
checked
.

.

,
,
( ).
149

char, 16 ( '\u0000' '\uffff'). ,


(
).


, float double, ,
IEEE 754 (
IEC 60559) [11,12]. ,
( float 23 8 ,
double 52 11 ).
-0.0 (, ,
0.0, 0.0,
-; -0.0
float 0x80000000,
double 0x8000000000000000), (
float 0x7f800000 0xff800000, double 0x7ff0000000000000 0xfff0000000000000),
NaN (Not-A-Number, ;
, , 0).
.

==, != . IEEE 754 NaN


, . -0.0 0.0.

<, <=, >, >= . + , -,


- . NaN ,
, false,
NaN. -0.0 , , 0.0.

+, -, *, /, % , , , , ,


. IEEE 754,
, , a b (b != 0)
a%b == a b*n, n
, |a/b|, a/b.
a%b b, a%b a.
IEEE 754
: 1.0/0.0 +, -1.0/0.0 -, 0.0/0.0 NaN,
x + +, ++(-) NaN. NaN,
NaN.

++, -- . NaN

.
Java java.lang.Float
java.lang.Double ,
,
,

NaN.
-23
127
Float.MAX_VALUE = (2-2 )2
-149
Float.MIN_VALUE = 2
-59
1023
Double.MAX_VALUE = (2-2 )2
-1074
Double.MIN_VALUE = 2
NaN

C# System.Single
System.Double
MaxValue, Epsilon,
PositiveInfinity, NegativeInfinity NaN.

150

POSITIVE_INFINITY,
NEGATIVE_INFINITY NaN.
C#
decimal ( System.Decimal).
128
,
, 96 , 5
,
0 28.
.
s (+1 -1),
m (0(296-1)) e (028)
(-1)sm10-e.
, ,
float double,
28-

. ,





.
decimal
, ,


.
-0.0, NaN .
Java ,
strictfp.
,


,
, IEEE 754.
,
float
,

.


. , .
x.y ,
, ( C#);
151

f(x) ( C#) ;

a[x] ( C#);

new ( C#),
new MyType("Yes", 2) ( Java

);

++, -- / 1;

+, - / ;

! ;

~ ;

*, /, %, +, - , , ,

(T)x T;

<<, >> /;

<, >, <=, >= ;

==, != /;

&, |, ^ : ,

, 2;

&&, || , (x && y)
(x?y:false), a (x || y) (x?true:y);

?: , a?x:y a,
true, x,
y;

=, *=, /=, %=, +=, -=, <<=, >>=, &=, |=, ^= , ,


,
,
.

x.y, f(x), a[x], new, x++, x-+, -, !, ~, ++x, --x, (T)x


*, /, %
+, <<, >>
<, >, <=, >=
==, !=
&
^
|
&&
||
?:
=, *=, /=, %=, +=, -=, <<=, >>=, &=, |=, ^=

10. .

152

10 ,
. op
, (x op y op z) ((x op y) op
z), , (x op (y op z)).
,
,
, ,
. , .
, , (reflection),
. (,
, .) .
, , .
Java
java.lang.Class,

java.lang.reflect.Method,

java.lang.reflect.Field.
Class,
T ( T = void),
T.class.
, x
T, Java
(x instanceof T),
.

, <, >, <=, >=.

C#
System.Type,
System.Reflection.MethodInfo,
System.Reflection.FieldInfo.

System.Type,
T,
typeof(T).

, x
T, C#
(x is T),
.

(
,
T)
/,

.
C# ,
.
x
T

(x as T),
T.

/, x
T,
null.
,
is, .

Java
>>>,
.
,
, .
153

>>>=
,
,
.
C# ,

( )

checked(x) (unchecked(x)),
x ,
(.
).

.
default(T) C# 2.0
T .
null,
0, false, a

.

,
,
,
.

.
?? (null coalescing operator)
C# 2.0 .
(x??y) ((x ==
null)?y:x), x
, .., x null,
x,
y.
,
||,
,
?:. .
C# 2.0 ::


.
, C# ,
,
,
,
.
, using
System.IO;,
FileStream ,

154

EmptyStream, ,
System.IO EmptyStream,
.

, , ,
System.IO SIO,
,
EmptyStream, MIO,

SIO.FileStream, MIO.EmptyStream.

MIO,
.

,
::.

. global
, ,

.
,
,
,
.

.
,
C#
unsafe.
,
(unsafe
context).

, ,
->,

,
.

C#,

[8].

Java C# C.
, .

; .

, , , , .
- .

155

( ).
, .
,
,
int[][] array = new int[][]{{0, 1}, {2, 3, 4}}; Ag
,
.

. :
o ;
o ,
(++, --), , ;
o ( C# );
o .

if(expression) statement Ag

if(expression) statement else statement1 Ag


expression ( ),
statement statement1 .

switch(expression) { } Ag

expression , case
, default. ,
default, ,
, case.
.
break;
expression ,

. C#
string.

, case, .
Java
break,
.

.

C#
( , default)
break,
goto default, goto case value ,
.
using System;

public class A
{
public static void main(String[] args)
{
if(args.length > 0)
{
int n = Integer.parseInt(args[0]);
switch(n)
{
case 0:
System.out.println("n = 0");
case 1:

public class A
{
public static void Main(string[] args)
{
if(args.Length > 0)
{
int n = Int32.Parse(args[0]);
switch(n)
{
case 0:
Console.WriteLine("n = 0");
goto case 1;
case 1:

156

Console.WriteLine
("n = 0 or n = 1");
break;
case 2:case 3:
Console.WriteLine
("n = 2 or n = 3");
break;
default:
Console.WriteLine
("n is out of [0..3]");
break;

System.out.println
("n = 0 or n = 1");
break;
case 2:case 3:
System.out.println
("n = 2 or n = 3");
break;
default:
System.out.println
("n is out of [0..3]");

}
}
else
System.out.println("No arguments");
}

}
}
else
Console.WriteLine("No arguments");

while do .
while(expression) statement Ag
do statement while(expression); Ag
expression , , statement .
C.
, , ,
. ,
.
for C.
for(A; B; C) statement Ag

A; while(B) { statement C; } Ag
A, B, C , B
( true), A (A
), .
for ,
.

Java

C#

for ( finalopt type id : expression )


statement

foreach ( type id in expression )


statement

expression
java.lang.Iterable .

(T
iterator() expression, v
).

expression ,

System.Collections.IEnumerable

for(T v = expression.iterator();
v.hasNext(); )
{
finalopt type id = v.next();
statement
}

, expression
T[],
(a, i
)

System.Collections.Generic.IEnumerable
<T>,
GetEnumerator(), ,
, Current
MoveNext().

GetEnumerator()
, ,
(enumerator type).
Current, ,
type.
E, e
. ,
,
157

.
T[] a = expression;
for(int i = 0; i < a.length; i++)
{
finalopt type id = v.next();
statement
}

E e = expression.GetEnumerator();
while(e.MoveNext())
{
type id = (type)e.Current;
statement
}


, (.
using).

:


:
using System;

public class A
{
public static void main(String[] args)
{
int i = 1;
for(String s : args)
System.out.println((i++) +
"-th argument is " + s);
}
}

public class A
{
public static void Main(string[] args)
{
int i = 1;
foreach (string s in args)
Console.WriteLine((i++) +
"-th argument is " + s);
}
}

break continue C.
break
. continue
, (..
), .
break continue try (. )
catch, finally,
finally.

Java break
,
( ,
).
, break ( continue)
.
/ (
),
. ( )
.

return
(, , ., . ).
, return
.
throw
. throw ,
.
(exception) , -
() ,
. -
, .
158

,
(. ),
.
.
.
java.lang.Throwable Java
System.Exception C#.
- , , .
o ( ,
).
Java String getMessage(), C#
string Message.
o ,
. -
, .
, null.
Java Throwable getCause(), C#
System.Exception.InnerException.
o , ,
, ,
.
, , ,
. , ,

Java .
,
, ,
.
Java
StackTraceElement[] getStackTrace(), .
(String getFileName()),
(String getClassName()) (String getMathodName()),
(int getLineNumber()).
C#
string StackTrace.
.
try
{ statements } Ag
catch ( type_1 e_1 ) { statements_1 } Ag
Ag
catch ( type_n e_n ) { statements_n } Ag
finally
{ statements_f } Ag
, try,
, catch,
. catch ,
finally .
finally try, ,
catch,
.
catch finally,
. C# - catch,
.
159

using System;
public class A
{
public static void main(String[] args)
{
try {
if(args.length > 0)
System.out.println
("Some arguments are specified");
else throw new
IllegalArgumentException
("No arguments specified");
}
catch(RuntimeException e)
{
System.out.println
("Exception caught");
System.out.println
("Exception type is " +
e.getClass().getName());
System.out.println
("Exception message is \"" +
e.getMessage() + "\"");
}
finally
{
System.out.println
("Performing finalization");
}
}
}

public class A
{
public static void Main(string[] args)
{
try {
if(args.Length > 0)
Console.WriteLine
("Some arguments are specified");
else throw new
ArgumentException
("No arguments specified");
}
catch(Exception e)
{
Console.WriteLine
("Exception caught");
Console.WriteLine
("Exception type is " +
e.GetType().FullName);
Console.WriteLine
("Exception message is \"" +
e.Message + "\"");
}
finally
{
Console.WriteLine
("Performing finalization");
}
}
}

Java, 1.4,
assert,
.
:
assert expression ;
assert expression : expression_s ;

expression
, expression_s
.

.
,
.
,
expression.
true, ,

java.lang.AssertionError.


expression_s,

.
C#
goto.
160

,
, goto.
, ,
goto case
default.
goto
switch, .
goto try
catch,
finally,
finally.
checked unchecked C#
,
(.
).
using
C#, ,
- ,

.

using ( expression ) statement
using ( declaration ) statement

declaration
.


T, v ,

using ( T v = expression ) statement

, ,
.
{
T v = expression;
try { statement }
finally { disposal }
}

disposal
Dispose(), T,
,
v null,
System.IDisposable, T
.
2.0 C#
yield,
.
, yield,
(iterator block)
,

161

finally, catch try,


catch-.

.

:
System.Collections.IEnumerable,
System.Collections.IEnumerator,
System.Collections.Generic.IEnumerable
<T>,
System.Collections.Generic.IEnumerator
<T>.


object, T.


yield return expression;

, object T.
,

,
yield break;

yield .
using System;
public class MyArrayList<T>
{
T[] items = new T[10];
int size = 0;
public int Count
{ get { return size; } }
public T this[int i]
{
get
{
if(i < 0 || i >= size) throw new
IndexOutOfRangeException();
else return items[i];
}
set
{
if(i < 0 || i > size) throw new
IndexOutOfRangeException();
else if (i == size)
{
T[] newItems =
new T[size + 10];
Array.Copy
(items, newItems, size++);
}
items[i] = value;
}
}

162

public IEnumerator<T> GetEnumerator


()
{
for(int i = 0; i < size; i++)
yield return items[i];
}

public class A
{
public static void Main()
{
MyArrayList<string> l =
new MyArrayList<string>();
l[0] = "First";
l[1] = "Second";
l[2] = "Third";

foreach (string s in l)
Console.WriteLine(s);

, ,
, ,
.


.
, .

== !=. C# , ,
, object.
,
. , . C#
, Java
.
,
.
(fields) .
, .
, .
, ,
, C# (. ).
.
, ,
, ,
.
.
() ,
.
C# .
, ,
.
163

. ,
abstract.
(static), .. ,
. ,
, . ,
, .
, ,
( ) .
, .
, (
, , C# ,
).
, Java, C#
. , , ,
( ) - .
,
, () .
( )
(generic), .. ( Java 5
C# 2.0).
.
.
, -,
, .
.
using System;
public interface Queue <T>
{
void put (T o);
T
get ();
int size();
}
public class LinkedQueue <T>
implements Queue <T>
{
public void put (T o)
{
if(last == null)
{
first = last = new Node <T> (o);
}
else
{
last.next = new Node <T> (o);
last = last.next;
}
size++;
}
public T
get ()
{
if(first == null) return null;
else
{
T result = first.o;
if(last == first) last = null;
first = first.next;

public interface IQueue <T>


{
void Put (T o);
T
Get ();
int Size();
}
public class LinkedQueue <T>
: IQueue <T>
{
public void Put (T o)
{
if(last == null)
{
first = last = new Node <T> (o);
}
else
{
last.next = new Node <T> (o);
last = last.next;
}
size++;
}
public T
Get ()
{
if(first == null) return default(T);
else
{
T result = first.o;
if(last == first) last = null;
first = first.next;

164

size--;
return result;

size--;
return result;
}

public int size()


{
return size;
}

public int Size()


{
return size;
}

private Node <T> last = null;


private Node <T> first = null;
private int
size = 0;

private Node <T> last = null;


private Node <T> first = null;
private int
size = 0;

private static class Node <E>


{

internal class Node <E>


{

E
Node<E>

}
}
public class Program
{
public static void main(String[] args)
{
Queue<Integer> q =
new LinkedQueue<Integer>();

internal E
o
= default(E);
internal Node <E> next = null;

o
= null;
next = null;

Node (E o)
{
this.o = o;
}

internal Node <E> (E o)


{
this.o = o;
}

}
}
public class Program
{
public static void Main()
{
Queue<int> q =
new LinkedQueue<int>();

for(int i = 0; i < 10; i++)


q.put(i*i);

for(int i = 0; i < 10; i++)


q.Put(i*i);

while(q.size() != 0)
System.out.println
("Next element + 1: " +
(q.get()+1));

while(q.Size() != 0)
Console.WriteLine
("Next element + 1: " +
(q.Get()+1));


Next
Next
Next
Next
Next
Next
Next
Next
Next
Next

element
element
element
element
element
element
element
element
element
element

+
+
+
+
+
+
+
+
+
+

1:
1:
1:
1:
1:
1:
1:
1:
1:
1:

1
2
5
10
17
26
37
50
65
82


. .
-,
.
.
Java
, , ,

C#
.
165

.
int[] array = new int[3];
String[] array1 =
new String[]{"First","Second"};
int[][] arrayOfArrays = new int[][]
{{1, 2, 3}, {4, 5}, {6}};


length,
.

int[] array = new int[3];


string[] array1 =
new string[]{"First","Second"};
int[][] arrayOfArrays = new int[][]
{{1, 2, 3}, {4, 5}, {6}};
int[,] twoDimensionalArray =
new int[,] {{1, 2}, {3, 4}};


System.Array, -
.
(
) ,
Length.
Rank.

(enums),
. .
Java ( Java 5)
,
. ,

(.. , ,
)
.



.
-,

==.

.

C#
,
( ;
int).

.

.

.

public enum Coin


{
PENNY ( 1),
NICKEY ( 5),
DIME
(10),
QUARTER(25);

public enum Coin : uint


{
PENNY
= 1,
NICKEY = 5,
DIME
= 10,
QUARTER = 25
}

Coin(int value)
{ this.value = value; }
public int value()
{ return value; }
private int value;
}

, Java
, C#.

166


.
public enum Operation
{
ADD {
public int eval(int a, int b)
{ return a + b; }
},
SUBTRACT {
public int eval(int a, int b)
{ return a - b; }
},
MULTIPLY {
public int eval(int a, int b)
{ return a * b; }
},
DIVIDE {
public int eval(int a, int b)
{ return a / b; }
};
public abstract int eval
(int a, int b);
}

C#
,
.
.

,
,
,

.
,
.

.

.

(0 , false
, null

).
.
public struct Point2D
{
private double x;
private double y;
public Point2D(double x, double y)
{
this.x = x;
this.y = y;
}

167

public double X() { return x; }


public double Y() { return y; }
}


object,
.
, ,
object
,
.

object
,
(autoboxing) ,
,
(auto-unboxing)
.

.
, ,
,
.


.

, ,
, .
Java, ,
(anonymous
classes).
-
.

- ,

. .

,
.
interface Stack <T>
{
void push(T o);
T
pop ();
}
public class B
{
public void m()
{
Stack<Integer> s =
new Stack<Integer>() {
final static int maxSize = 10;
int[] values = new int[maxSize];
int last = -1;

168

public void push(Integer i) {


if(last + 1 == maxSize)
throw new
TooManyElementsException();
else values[++last] = i;
}
public Integer pop() {
if(last 1 < -1)
throw new
NoElementsException();
else return values[last--];
}
};

s.push(3);
s.push(4);
System.out.println(s.pop() + 1);

C# 2.0
(nullable)

,
,
null.

[8], [9].

,
.
bool? mayBeNullFlag
= null;
int? mayBeNullNumber
= 5;
Point2D? mayBeNullPoint = null;

T?
System.Nullable<T>.
HasValue, true ,
T, null,
Value, ,
null.

T T?.
,
, .

null,
null.
(<, >, <=, >=)
false, null.


null.
bool? & |
null,
169

. .. false & null ==


false, true | null == true.
,
.
??,

.
a??b (a != null)?a:b.
,
C#
,
C (delegate
types).
,
,
.



(anonymous
method, C# 2.0) [9].

BinaryOperation 6
,
.
op1 op3
A.Op1(),
op2 op4 Op2(),
a, op5 op6
.
public delegate int BinaryOperation
(int x, int y);
public class A
{
private int x = 0;
public A(int x) { this.x = x; }
public static int Op1(int a, int b)
{ return a + b; }
public int Op2(int a, int b)
{ return x + a + b; }
public static A a = new A(15);
BinaryOperation op1 = A.Op1;
BinaryOperation op2 = a.Op2;
BinaryOperation op3 =
new BinaryOperation(A.Op1);
BinaryOperation op4 =
new BinaryOperation(a.Op2);
BinaryOperation op5 =
delegate(int c, int d)
{ return c * d; };
BinaryOperation op6 =
delegate { return 10; };
}

170

,

. ..

.


.
-
(invocation list).
null.

+ +=,
( ,

, op1 op2
).



.
.

- -=.



.


. ,
null.
,

.
,
.

. null,

System.NullReferenceException.
using System;
public class A
{
delegate void D();
static void M1()
{ Console.WriteLine("M1 called"); }
static void M2()
{ Console.WriteLine("M2 called"); }
public static void Main()
{

171

D d1 = M1, d2 = M2;
d1 += M1;
d2 = d1 + d2 + d1;

d1();
Console.WriteLine("------------");
d2();
Console.WriteLine("------------");
(d1 + d2)();
Console.WriteLine("------------");
(d1 - d2)();
Console.WriteLine("------------");
(d2 - d1)();


.
M1 called
M1 called
-----------M1 called
M1 called
M2 called
M1 called
M1 called
-----------M1 called
M1 called
M1 called
M1 called
M2 called
M1 called
M1 called
-----------M1 called
M1 called
-----------M1 called
M1 called
M2 called


Java C#.

10
[1] J2SE http://java.sun.com/j2se/index.jsp.
[2] J2EE http://java.sun.com/j2ee/index.jsp.
[3] J2ME http://java.sun.com/j2me/index.jsp.
[4] Java Card http://java.sun.com/products/javacard/index.jsp.
[5] .NET http://www.microsoft.com/net/developers.mspx.
[6] Mono http://www.mono-project.com/Main_Page.
[7] J. Gosling, B. Joy, G. Steele, and G. Bracha. Java Language Specification, 3-rd edition. Addison
Wesley Professional, 2005.
http://java.sun.com/docs/books/jls/download/langspec-3.0.pdf.
[8] C# Language Specification. Working Draft 2.7. ECMA, June 2004.
http://download.microsoft.com/download/8/1/6/81682478-4018-48fe-9e5ef87a44af3db9/standard.pdf.
[9] C# Langauge Specification 2.0, March 2005 Draft.
http://download.microsoft.com/download/8/1/6/81682478-4018-48fe-9e5ef87a44af3db9/CSharp%202.0%20Specification.doc.
172

[10] The Unicode Consortium. The Unicode Standard, Version 4.0. Boston, MA, Addison-Wesley
Developers Press, 2003.
[11] IEEE 754-1985 IEEE Standard for Binary Floating-Point Arithmetic. Revised 1990, IEEE, New
York, 1990.
[12] IEC 60559:1989 Binary floating-point arithmetic for microprocessor systems. (2-nd ed.,
previously designated IEC 559:1989) International Electrotechnical Commission, 1989.

173

11. Java C# ()

Java #.
,
. Java .NET.


, , , , , ,
, , , , , , ,
.


Java 5 C# 2.0
[1] [2,3].

. ,
, ,
, .. .
.
, ,
.

. .
, , Java final, C#
sealed.
Java ( !)

java.lang.Object.

, .

C# , ,
( !)

System.Object,
object.
, ,
( ,
System.ValueType)
object ,
.

,

.

, .. ,
. - ,
, -.
, .
,
, , ..
. ,
, .. ClassName.fieldName, -
super.fieldName Java base.fieldName C# (,
- , ).
174

super Java base C# ,


.
this, ,
.
(override)
-. ,
,
, , .
(virtual).
, .
,
(Liskov substitution principle) [4,5]. -
, -, ,
-. , ,
.
, ,
. -,
.
,
, ,
. ,
.
, , , .
, ,
.

Java
, ..

-.
Java, C#,


( , this).


.

C# (
,
) , ..
, .
(,
)
virtual. (,
, ),
-
override.
,

(.. ),
new.
, virtual,

.

,
.


.
using System;
class A
{
public void m()

class A
{
public virtual void m()

175

{
}

{
System.out.println("A.m() called");

public static void n()


{
System.out.println("A.n() called");
}

Console.WriteLine("A.m() called");

public void n()


{
Console.WriteLine("A.n() called");
}

class B extends A
{
public void m()
{
System.out.println("B.m() called");
}

class B : A
{
public override void m()
{
Console.WriteLine("B.m() called");
}

public static void n()


{
System.out.println("B.n() called");
}

public new void n()


{
Console.WriteLine("B.n() called");
}

public class C
{
public static void main(String[] args)
{
A a = new A();
B b = new B();
A c = new B();

public class C
{
public static void Main()
{
A a = new A();
B b = new B();
A c = new B();

a.m();
b.m();
c.m();
System.out.println("-----");
a.n();
b.n();
c.n();
}


.
A.m()
B.m()
B.m()
----A.n()
B.n()
A.n()

called
called
called
called
called
called

a.m();
b.m();
c.m();
Console.WriteLine("-----");
a.n();
b.n();
c.n();


new n() B,
,
,
.

.
A.m()
B.m()
B.m()
----A.n()
B.n()
A.n()

called
called
called
called
called
called


(members) , (
) . ,
.
, ,
.
176

,
. , , .
,
,
( ) ( ,
static).
public,
protected private, , , ,
, -
, . ,
.
( ,
C#) (abstract), ..
. ( ,
C#) abstract.
.
(, C#),
, Java final, C#
sealed.
, .
C# .NET ,
.NET,
.NET .
Java Java Native Interface, JNI [6,7]. Java
, native.
.
C ( ,
C). , ,
, ,
, C .NET, C#
extern.
Java, ,
.
.

, ,
.

C# , , ,
,
, ,
, .
,
.
,

.
,
.

, C#,
JavaBeans [8,9],
Java
,
JavaBeans .
C# , JavaBeans.
Java
final static.
final ,



,
177



(. ),
, ,
.

.
.

public class A2
{
public static final double PHI =
1.61803398874989;
}

public class A2
{
public const double Phi =
1.61803398874989;
}

JavaBeans
(property) A,
name T,
, A T
getName() void setName(T),
(accessor methods)
.

, get,
, set.
,

isName().

Java ,
,

JavaBeans.


C#.

(properties)
.
get set,
,
.

. set
value
.
(,
get)
(,
set)
, .

.

.

using System;
public class MyArrayList
{
private int[] items = new int[10];
private int size = 0;

public class MyArrayList


{
private int[] items = new int[10];
private int size = 0;

public int getSize()


{
return size;
}

public int Size


{
get { return size; }
}

public int getCapacity()


{
return items.Length;
}

public int Capacity


{
get { return items.Length; }
set
{
int[] newItems = new int[value];
Array.Copy
(items, newItems, size);
items = newItems;
}
}

public void setCapacity(int value)


{
int[] newItems = new int[value];
System.arraycopy
(items, 0, newItems, 0, size);
items = newItems;
}
public static void main(String[] args)
{

public static void Main()


{

178

MyArrayList l = new MyArrayList();


System.out.println(l.getSize());
System.out.println(l.getCapacity());
l.setCapacity(50);
System.out.println(l.getSize());
System.out.println(l.getCapacity());
}

JavaBeans
(indexed property) A,
name T, T
getName(int) void setName(int, T).

.


,
. 1997 ,
JavaBeans [9],
.

MyArrayList l = new MyArrayList();


Console.WriteLine( l.Size );
Console.WriteLine( l.Capacity );
l.Capacity = 50;
Console.WriteLine( l.Size );
Console.WriteLine( l.Capacity );
}


(indexer) ,
.
C#

. ..
,
.
( ,
.. ) ,
() ,

.

.
.
-

base[].

.
using System;

public class MyArrayList


{
int[] items = new int[10];
int size = 0;
public int getItem(int i)
{
if (i < 0 || i >= 10) throw new
IllegalArgumentException();
else return items[i];
}
public void setItem(int i, int value)
{
if (i < 0 || i >= 10) throw new
IllegalArgumentException();
else items[i] = value;
}
public static void main(String[] args)
{
MyArrayList l = new MyArrayList();
l.setItem(0, 23);
l.setItem(1, 75);
l.setItem(1, l.getItem(1)-1);
l.setItem(0,

public class MyArrayList


{
int[] items = new int[10];
int size = 0;
public int this[int i]
{
get
{
if (i < 0 || i >= 10) throw new
IndexOutOfRangeException();
else return items[i];
}
set
{
if (i < 0 || i >= 10) throw new
IndexOutOfRangeException();
else items[i] = value;
}
}
public static void Main()
{
MyArrayList l = new MyArrayList();
l[0] = 23;
l[1] = 75;
l[0] += (--l[1]);
Console.WriteLine(l[0]);

179

l.getItem(0) + l.getItem(1));
System.out.println (l.getItem(0));
System.out.println (l.getItem(1));
}

(events) JavaBeans
(listeners)
-
(source).
EventType ,
,
java.util.EventObject.
-
EventListener,

( ,
) EventType.
EventListener
java.util.EventListener.


.
public void addEventListener
(EventListener)
public void removeEventListener
(EventListener).

,

.
public

.
public class MouseEventArgs { ... }

Console.WriteLine(l[1]);

(event)
, .
, ,
add remove

,
(

JavaBeans)
+= -=.

,
event.
add remove

+=
-= .

, add
remove.

-,
add
remove, .

.
public class MouseEventArgs { ... }

public class MouseEventObject


extends java.util.EventObject
{
MouseEventArgs args;

MouseEventObject
(Object source, MouseEventArgs args)
{
super(source);
this.args = args;
}

public interface MouseEventListener


extends java.util.EventListener
{
void mouseUp(MouseEventObject e);
void mouseDown(MouseEventObject e);
}

public delegate void MouseEventHandler


(object source, MouseEventArgs e);

import java.util.ArrayList;
public class MouseEventSource

public class MouseEventSource

180

private ArrayList<MouseEventListener>
listeners = new ArrayList
<MouseEventListener >();

private MouseEventHandler mouseDown;


public event
MouseEventHandler MouseDown
{
add
{
lock(this)
{ mouseDown += value; }
}
remove
{
lock(this)
{ mouseDown -= value; }
}
}

public synchronized void


addMouseEventListener
(MouseEventListener l)
{ listeners.add(l); }
public synchronized void
removeMouseEventListener
(MouseEventListener l)
{ listeners.remove(l); }

protected void notifyMouseUp


(MouseEventArgs a)
{
MouseEventObject e =
new MouseEventObject(this, a);
ArrayList<MouseEventListener> l;
synchronized(this)
{
l =
(ArrayList<MouseEventListener>)
listeners.clone();
for(MouseEventListener el : l)
el.mouseUp(e);
}
}

protected void
OnMouseUp(MouseEventArgs e)
{
MouseUp(this, e);
}

protected void notifyMouseDown


(MouseEventArgs a)
{
MouseEventObject e =
new MouseEventObject(this, a);

ArrayList<MouseEventListener> l;
synchronized(this)
{
l =
(ArrayList<MouseEventListener>)
listeners.clone();
for(MouseEventListener el : l)
el.mouseDown(e);
}

public class HandlerConfigurator


{
MouseEventSource s =
new MouseEventSource();
MouseEventListener listener =
new MouseEventListener()
{
public void mouseUp
(MouseEventObject e) { ... }
public void mouseDown
(MouseEventObject e) { ... }
};

public event MouseEventHandler MouseUp;

protected void
OnMouseDown(MouseEventArgs e)
{
mouseDown(this, e);
}

public class HandlerConfigurator


{
MouseEventSource s =
new MouseEventSource();
public void UpHandler
(object source, MouseEventArgs e)
{ ... }
public void DownHandler
(object source, MouseEventArgs e)
{ ... }

181

public void configure()


{
s.addMouseEventListener(listener);
}
}

public void Configure()


{
s.MouseUp += UpHandler;
s.MouseDown += DownHandler;
}

,
-
, .., ,
,
.
C# 2.0
.
,
,
.
:
public int Property
{
get { }
protected set { }
}

Java
.
,
,
,
, +
( java.lang.String),
.
+
,
String.


toString()
.

C#
()
.
static.
(
,
,
): +, -, !, ~ (
), ++,-- (

), true, false (
bool).
(

,
): +, -, *, /, %, &, |, ^, <<,
>>, ==, !=, <, >, <=, >=. <<
>>
,
int.


,

implicit,
,
.
explicit
.

true false, == !=, < >,
182

<= >=.

true false

.
T & |,
,
true false,

&& ||.
(x && y)
= (T.false(x)? x : (x & y)) (x || y) =
(T.true(x)? x : (x | y)).


,
+, -, *, /, %, &, |, ^, << >>.

. ,
MyInt int
,
.

MyInt object
AreEqual ,
==
, i1 ==
null
.
using System;
public class MyInt
{
int n = 0;
public MyInt(int n) { this.n = n; }
public override bool Equals(object obj)
{
MyInt o = obj as MyInt;
if (o == null) return false;
return o.n == n;
}
public override int GetHashCode()
{ return n; }
public override string ToString()
{ return n.ToString(); }
public static bool AreEqual
(MyInt i1, MyInt i2)
{
if ((object)i1 == null)
return ((object)i2 == null);
else return i1.Equals(i2);
}

183

public static bool operator ==


(MyInt i1, MyInt i2)
{ return AreEqual(i1, i2); }
public static bool operator !=
(MyInt i1, MyInt i2)
{ return !AreEqual(i1, i2); }
public static bool operator true
(MyInt i)
{ return i.n > 0; }
public static bool operator false
(MyInt i)
{ return i.n <= 0; }
public static MyInt operator ++
(MyInt i)
{ return new MyInt(i.n + 1); }
public static MyInt operator -(MyInt i)
{ return new MyInt(i.n - 1); }
public static MyInt operator &
(MyInt i1, MyInt i2)
{ return new MyInt(i1.n & i2.n); }
public static MyInt operator |
(MyInt i1, MyInt i2)
{ return new MyInt(i1.n | i2.n); }
public static implicit operator int
(MyInt i)
{ return i.n; }
public static explicit operator
MyInt (int i)
{ return new MyInt(i); }

Java
protected void finalize(),

public static void Main()


{
MyInt n = (MyInt)5;
MyInt k = (MyInt)(n - 3 * n);
Console.WriteLine("k = " + k +
" , n = " + n);
Console.WriteLine("n == n : " +
(n == n));
Console.WriteLine("n == k : " +
(n == k));
Console.WriteLine(
"(++k) && (n++) : " +
((++k) && (n++)));
Console.WriteLine("k = " + k +
" , n = " + n);
Console.WriteLine(
"(++n) && (k++) : " +
((++n) && (k++)));
Console.WriteLine("k = " + k +
" , n = " + n);
}


- ,
.NET,
184

.
, C#,

,
.


.


.NET.

.
,
,
~

using System;

public class MyFileReader


{
java.io.FileReader input;

public class MyFileStream


{
System.IO.FileStream input;

public MyFileReader(String path)


throws FileNotFoundException
{
input = new java.io.FileReader
(new java.io.File(path));
}

public MyFileStream(string path)


{
input = System.IO.File.Open
(path, System.IO.FileMode.Open);
}

protected void finalize()


{
System.out.println("Destructor");
try { input.close(); }
catch (IOException e)
{
e.printStackTrace();
}
}

~MyFileStream()
{
Console.WriteLine("Destructor");
input.Close();
}


,

.


, =

,
.

, static


Java-.


,
.NET, ..

.
Java.

static.
using System;

public class A
{
static

public class A
{
static A()

185

{
}

System.out.println("Loading A");

static int x = 1;
static
{
System.out.println("x = " + x);
x++;
}

A");
x);
x);
y);

static int x = 1;
static int y = 2;

static int y = 2;
static
{
y = x + 3;
System.out.println("x = " + x);
System.out.println("y = " + y);
}

Console.WriteLine("Loading
Console.WriteLine("x = " +
x++;
y = x + 3;
Console.WriteLine("x = " +
Console.WriteLine("y = " +

public static void Main() {}


}

public static void main(String[] args)


{}

Loading A
x = 1
x = 2
y = 5

Loading A
x = 1
x = 2
y = 5

Java



.

,
.
, ,

- , .
, ,
, ,

, ,
, .


ClassName.this, ClassName
.


,
.

C# static , ,
, ,

.

static.

public class ContainingClass


{
static int counter = 1;
static int ecounter = 1;

186

int id = counter++;
class EmbeddedClass
{
int eid = ecounter++;

public String toString()


{
return "" +
ContainingClass.this.id +
'.' + eid;
}

public String toString()


{
return "" + id;
}
public static void main
(String[] args)
{
ContainingClass
c = new ContainingClass()
, c1 = new ContainingClass();
System.out.println(c);
System.out.println(c1);

EmbeddedClass
e = c.new EmbeddedClass()
, e1 = c.new EmbeddedClass()
, e2 = c1.new EmbeddedClass();
System.out.println(e);
System.out.println(e1);
System.out.println(e2);

C#
(, ,
, ) ,

.


.
using System;
public interface I1
{
void m();
}
public interface I2
{
void m();
}
public class A : I1, I2
{
public void m()
{
Console.WriteLine("A.m() called");
}

187

void I1.m()
{
Console.WriteLine
("I1.m() defined in A called");
}
void I2.m()
{
Console.WriteLine
("I2.m() defined in A called");
}
public static void Main()
{
A f = new A();
I1 i1 = f;
I2 i2 = f;

f.m();
i1.m();
i2.m();


.
A.m() called
I1.m() defined in A called
I2.m() defined in A called

-
Java C# .
, ,
.
using System;
public class A
{
static
{
System.out.println
("Static initializer of A");
}
{
}

public class A
{
static A()
{
Console.WriteLine
("Static constructor of A");
}

System.out.println
("Initializer of A");

static int sinit()


{
System.out.println
("Static field initializer of A");
return 0;
}

static int sinit()


{
Console.WriteLine
("Static field initializer of A");
return 0;
}

static int init()


{
System.out.println
("Field initializer of A");
return 0;
}

static int init()


{
Console.WriteLine
("Field initializer of A");
return 0;
}

static int sf = sinit();

static int sf = sinit();

188

int f = init();

int f = init();

public A()
{
System.out.println
("Constructor of A");
}

public A()
{
Console.WriteLine
("Constructor of A");
}

public class B extends A


{
static int sf = sinit();
int f = init();

public class B : A
{
static int sf = sinit();
int f = init();
static B()
{
Console.WriteLine
("Static constructor of B");
}

static
{
System.out.println
("Static initializer of B");
}
{
}

System.out.println
("Initializer of B");

static int sinit()


{
System.out.println
("Static field initializer of B");
return 0;
}

static int sinit()


{
Console.WriteLine
("Static field initializer of B");
return 0;
}

static int init()


{
System.out.println
("Field initializer of B");
return 0;
}

static int init()


{
Console.WriteLine
("Field initializer of B");
return 0;
}

public B()
{
System.out.println
("Constructor of B");
}

public B()
{
Console.WriteLine
("Constructor of B");
}

public class C
{
public static void main(String[] args)
{
B b = new B();
}
}

public class C
{
public static void Main()
{
B b = new B();
}
}

Static initializer of A
Static field initializer of A
Static field initializer of B
Static initializer of B
Initializer of A
Field initializer of A
Constructor of A
Field initializer of B
Initializer of B
Constructor of B

Static field initializer of B


Static constructor of B
Field initializer of B
Static field initializer of A
Static constructor of A
Field initializer of A
Constructor of A
Constructor of B

189

Java , ,

private, protected public,
.
,
.

Java .
protected Java
,
, .. protected .
, ,
public (
),
.

Java

final,
transient volatile.
final ,
,
:

,
.

.
final



.
, transient,

,
.
Java ,
,



java.io.Serializable,
.
,

C#
private.

internal. ,
,
,
.
, C#
protected
internal ,

,
.
, ,
public,
private, ,

.
C#
new ,


.
C#

readonly volatile.
readonly
final Java.
readonly

.


,
,
,
.

190


Java.
Java,
,

java.io.Serializable,
,
transient.
Java

strictfp (
) synchronized.
strictfp
10,
.
synchronized
, ,
.


, .. ,
.
Java C#.
getTypeName()
, .
, .
using System;
public class A
{
public static <T> String getTypeName
(T a)
{
if(a == null) return "NullType";
else return
a.getClass().getName();
}

public class A
{
public static string getTypeName<T>
(T a)
{
if(a == null) return "NullType";
else return
a.GetType().FullName;
}
public static void Main()
{
string y = "ABCDEFG";

public static void main(String[] args)


{
String y = "ABCDEFG";

System.out.println( getTypeName(y) );
System.out.println
( getTypeName(y.length()) );
System.out.println
( A.<Character>getTypeName
(y.charAt(1)) );

Java
.


-.

Console.WriteLine( getTypeName(y) );
Console.WriteLine
( getTypeName(y.Length) );
Console.WriteLine
( getTypeName<char>(y[1]) );
}

C#
.

191

Java



,
.


.

C# ,


,

.

using System;
public class A<T>
{
public static int c = 0;
public T t;
}

public class A<T>


{
public static int c = 0;
public T t;
}

public class B
{
public static void main
(String[] args)
{
A.c = 7;

public class B
{
public static void Main()
{
A<string>.c = 7;

Console.WriteLine( A<int>.c );
Console.WriteLine( A<string>.c );

System.out.println( A.c );
}

C#
.
public delegate bool Predicate<T>
(T value);
public class I
{
public bool m(int i)
{ return i == 0; }

public void f()


{
Predicate<int> pi = m;
Predicate<string> ps =
delegate(string s)
{ return s == null; };
}


. ,
-, ,
.
, - ,
- .
Java , -

/
.
T
A
B.

C# , -
, ,
/
,
.
T
, V
192

, U
A, IList<T>
.
public class A
{
public int m() { ... }
}
public interface B
{
public String n();
}

public class A { ... }


public class B<T, U, V>
where T : class
where U : A, IList<T>, new()
where V : struct
{ ... }

public class C<T extends A & B>


{
T f;

public String k()


{
return f.n() + (f.m()*2);
}

, Java

(wildcards) .


, ,
.

,
,
,
.

,

.

,
, (
) T,
,
T.
public class A
{
public void addAll
(Collection<?> c)
{ ... }
public <T> void addAll
(Collection<? extends T> c)
{ ... }

public <T> void addToCollection


(T e, Collection<? super T> c)
{ ... }

193


( Java 5) ,
( printf
C). .
.
,
, .
.
Java ,
.

C# params,
.
using System;

public class A
{
public int f(int ... a)
{
return a.length;
}

public class A
{
public int f(params int[] a)
{
return a.Length;
}
public static void Main
{
A a = new A();

public static void main(String[] args)


{
A a = new A();

System.out.println
( a.f(new int[]{9, 0}) );
System.out.println
( a.f(1, 2, 3, 4) );
}

Console.WriteLine
( a.f(new int[]{9, 0}) );
Console.WriteLine
( a.f(1, 2, 3, 4) );

C# ,
Java
, ,
.
, .
,
(checked)
(unchecked).
,

, null,

, .



.

, java.lang.Error,
,

, java.lang.RuntimeException,

Java.

, .
,

,
194

throws.
,

T,
try-,
T
,
T
,
.
public void m(int x)
throws MyException
{
throw new MyException();
}
public void n(int x)
throws MyException
{
m(x);
}
public void k(int x)
{
try { m(x); }
catch(MyException e)
{ ... }
}

Java
.
, ,
,
.
,
,
.

C# ,
,
.
, ,
ref.
out.

.
using System;
public class A
{
public void f
(int a, ref int b, out int c)
{
c = b - a;
b += a;
}
public static void Main()
{
A a = new A();
int n = 3, m = 0;

Console.WriteLine
("n = " + n + " , m = " + m);
a.f(1, ref n, out m);
Console.WriteLine
("n = " + n + " , m = " + m);

195


( Java 5)
, , .
, ,
Java (annotations), C# (attributes).
.
, ,
. , ,

. ,
, , .
,
,
. , ,
,
.
,
.
.
,
. A ,
, (, ,
), , n()
. n() .
@interface SimpleMethodAnnotation {}

class SimpleMethodAttribute
: Attribute
{}

@interface SimpleParameterAnnotation{}

class SimpleParameterAttribute
: Attribute
{}

@interface ComplexClassAnnotation
{

class ComplexClassAttribute
: Attribute
{
public int id;
public String author =
"Victor Kuliamin";
public String date;
}

int id();
String author() default
"Victor Kuliamin";
String date();

class AdditionalMethodAttribute
: Attribute
{
public String value = "";
}

@ComplexClassAnnotation
(
id
= 126453,
date
= "23.09.2005"
)
public class A
{
@SimpleMethodAnnotation
public void m() { ... }

[ComplexClassAttribute
(
id
= 126453,
date
= "23.09.2005"
)]
public class A
{
[SimpleMethodAttribute]
public void m() { ... }

@SimpleMethodAnnotation

[SimpleMethodAttribute,

@interface AdditionalMethodAnnotation
{
String value() default "";

196

@AdditionalMethodAnnotation
( value = "123" )
public void n
(@SimpleParameterAnnotation int k)
{ ... }

Java
(..
, ),

.


@interface

java.lang.annotation.Annotation.

.

,
.

<
> = <>.
,
(public static
final ) ,
.

AdditionalMethodAttribute
(value = "123")]
public void n
([SimpleParameterAttribute] int k)
{ ... }

C# ,
,
.
.

,
.
,
System.Attribute
.
.



.

.


.


, <
> = <>.

, .

.
class ClassAttribute : Attribute
{
public ClassAttribute(int id)
{
this.id = id;
}
int id;
public string value;
}
[ClassAttribute(4627, value = "")]
public class A { ... }


, String, Class,
Class,
,

.


bool, byte, char, double, float, int,
long, short, string, object, System.Type,

.

197

,
. ,
,
assembly
.
[assembly :
MyAttribute
(
id = 4627,
author = "Victor Kuliamin"
)]

C# ,
Attribute

.
,
ClassAttribute,
ClassAttribute,
Class.

Class
ClassAttribute.


.

@. @Class,

Class.


Java, C# . ,
(threads),
. ,
. (
Java .NET) , ,
, .
(java.lang.Thread Java
System.Threading.Thread C#).
.
Java .
-
java.lang.Thread
public void run(). ,

.
,
java.lang.Runnable
void run().
Thread
.

C# .

, ,
- .
,
.
void.

,
object.

198


Thread
( ) void
start().


System.Threading.ThreadStart,
System.Threading.
ParameterizedThreadStart.


System.Thread.

Start() Thread
, Start(object) .
using System;
using System.Threading;
class T extends Thread
{
int id = 0;
public T(int id)
{ this.id = id; }

public void run()


{
System.out.println
("Thread " + id + " is working");
}

public class A
{
public static void main(String[] args)
{
Thread th1 = new T(1),
th2 = new T(2),
th3 = new Thread(
new Runnable() {
public void run()
{
System.out.println
("Runnable is working");
}
});

class T
{
int id;
public T(int id)
{ this.id = id; }

public void m()


{
Console.WriteLine
("Thread " + id + " is working");
}

public class A
{
static void m()
{
Console.WriteLine
("Nonparameterized thread" +
" is working");
}
static void m(object o)
{
Console.WriteLine
("Thread with object " + o +
" is working");
}

th1.start();
th2.start();
th3.start();

public static void Main()


{
Thread th1 = new Thread(
new ThreadStart(m)),
th2 = new Thread(
new ThreadStart(new T(1).m)),
th3 = new Thread(
new ParameterizedThreadStart(m));

th1.Start();
th2.Start();
th3.Start(2);

, ,
.
, , .
, .
,
199

, .

, -
(deadlocks),
, .
, ,
(monitor). ,
.
,
, , .
, ,
.
,
, . (
), -
synchronized Java lock C#.
using System;
using System.Threading;
public class PingPong extends Thread
{
boolean odd;
PingPong (boolean odd)
{ this.odd = odd; }

public class PingPong


{
bool odd;
PingPong (bool odd) { this.odd = odd; }

static int counter = 1;


static Object monitor = new Object();

static int counter = 1;


static object monitor = new object();

public void run()


{
while(counter < 100)
{
synchronized(monitor)
{
if(counter%2 == 1 && odd)
{
System.out.print("Ping ");
counter++;
}
if(counter%2 == 0 && !odd)
{
System.out.print("Pong ");
counter++;
}
}
}
}

public void Run()


{
while(counter < 100)
{
lock(monitor)
{
if(counter%2 == 1 && odd)
{
Console.Write("Ping ");
counter++;
}
if(counter%2 == 0 && !odd)
{
Console.Write("Pong ");
counter++;
}
}
}
}

public static void main


(String[] args)
{
Thread th1 = new PingPong (false),
th2 = new PingPong (true);

public static void Main()


{
Thread th1 = new Thread(
new ThreadStart(
new PingPong(false).Run)),
th2 = new Thread(
new ThreadStart(
new PingPong(true).Run));

th1.start();
th2.start();

th1.Start();
th2.Start();

200

, Java
synchronized. ,


,
, .

,
this, ,

this.getClass(), ,
.
Java


.
java.lang.Object
wait(),
,
notify() notifyAll()
, .
,
.

.


java.util.concurrent
java.util.concurrent.locks,
JDK 5 (. ).

, Java, .NET,
.
.

.
Java
.

J2SE J2EE. .NET , , ,
Microsoft .
, . [10] [11].
Java
java.lang.

Java java.lang.Object.
.
boolean equals(Object)

, .

C#
System mscorlib.
C#
System.Object,
object.
bool Equals(object)
equals() Java.
static bool Equals(object, object)
201

Equals()

null.
int hashCode()
static bool ReferenceEquals(object,
,
object)
.
.
equals().
int GetHashCode()
String toString()
hashCode() Java.
, .
Object Equals().
JVM.
string ToString()
toString() Java. object
Class<? extends Object> getClass()
.
,
.
System.Type GetType() ,
.
protected void finalize()
protected object MemebrwiseClone()
. .
,
.
protected Object clone()
,
. Object
,

java.lang.Cloneable,
.
void wait(), void wait(long timeout), void
wait(long timeout, int nanos) ,

notify() notifyAll()

.
void notify(), void notifyAll() ,
,
.
,
.

System
Environment.
.

.
GetEnvironmentVariables()
in, out err GetEnvironmentVariable()
,
,
. , Exit(int)

,
setIn(), setOut() setErr().

, TickCount,
long currentTimeMillis() long

nanoTime()
, .
.
-
void exit(int status)
Java , Console.
.
In, Out, Err,

void gc() .

,

.
Object .

202

.
getenv(), getProperties()
getProperty()
Java
,
d.
load(), loadLibrary()
, , native
.
void arraycopy()
.
int identityHashCode(Object)

Java .
,
, Runtime.

String, StringBuffer StringBuilder
( Java 5).

CharSequence.
String
, .
,
StringBuffer ,
StringBuilder . ,

,
,
.
java.lang -
Boolean, Byte, Character,
Short, Integer, Long, Float, Double.

java.lang.Number.
,

,


,
.

java.text.NumberFormat
java.text.DecimalFormat.


java.lang.Math.

Math.random(),


System.String,
, System.Text.StringBuilder,
.

C#

System.
Boolean, Byte, SByte, Int16, Int32, Int64,
UInt16, UInt32, UInt64, Single, Double,
Decimal.

.


Parse() ToString()
,
IFormatProvider.
System.Globalization.
NumberFormatInfo.


System.Math.

System.Random.
203


java.util.Random.

java.math
BigInteger BigDecimal,

.
java.lang.Thread ,
Java .
,

(interrupt()),
(join()),
(start()),
- (sleep()),
(currentThread()),

(, , .).
java.lang.ThreadLocal
,
. .. ,
get()
, ,
set().
java.lang
.
CharSequence
.
Cloneable
, .
,
clone(),

Object.
Iterable<T>
. ,
, , ,

.
Comparable<T> ,
,
, ..

/. , ,
.
java.lang
,
Class<T>,
, Enum<T>,
,

, .NET C#,
System.Threading.Thread.

CurrentThread.
Interrupt(),
Join(), Start(), Sleep() .

C# .
System.ICloneable
Clone() .
System.Collections.IEnumerable,

System.Collections.Generic.
IEnumerable<T>

.
System.IComparable, System.IComparable<T>
,
.
C#, Java,
,


C# 2.0
.

C#
System.Type,
System.ValueType, System.Enum ,

System.Reflection MemberInfo, MethodInfo,
204

Package, .

, ,
java.lang.reflect (Field, Method,
Constructor)
(reflection)

.

, Java,
JavaBeans.


java.lang.reflect.Array,

, ,
.
,
, .
java.util.Arrays.

FieldInfo, ..

Java
System.Array.

, ,
,
.

, . ,
,
,
.
,
, , ..
.
java.lang.ref
.
,
java.lang.ref.WeakReference
.

.
java.util
,
.
Collection<T>
Java.
Collections

:
, ,
.
Set<T>, HashSet<T>, TreeSet<T>

. TreeSet<T> ,
T ,
(

) ,

C#
System.WeakReference.

C#

System.Collections
System.Collections.Generic.

,
.
,
.

Generic.IEnumerable<T>,
Generic.ICollection<T>.
,

Generic.IDictionary<K, V>,
Generic.Dictionary<K, V>, Hastable
().
205

.
Map<K, V>, HashMap<K, V>, TreeMap<K, V>


(maps)
. TreeMap<K, V> ,
-
,
.
List<T>, ArrayList<T>, LinkedList<T>

.
BitSet
-.
IdentityHashMap<K, V>
,
, equals(),
Map<K,
V> ( Set<T>).
WeakHashMap<K, V>
,

-, -
.
-
, ,
Jakarta Commons [12],
Apache Jakarta Project [13].

T
java.util.Comparator<T>.

java.text.Collator,
,
,
,
, .
java.util.Calendar,
java.util.GregorianCalendar,
java.util.Date java.text.DateFormat
.

,
Date
,

.

.


Generic.IList<T>, Generic.List<T>,
ArrayList ().
BitArray
.

C#
System.Collections.Generic. IComparer<T>.


System.StringComparer.



System.Globalization.Calendar,

System.Globalization.

System.DateType.
System.TimeSpan.


System.Globalization. DateTimeFormatInfo.

206

Joda [14].
java.util.Timer
java.util.TimerTask

.

, ,
java.util.Formatter.

java.util.Formattable

.

java.util ,
-
-
Currency
.

Locale.
,
, ,
,
ResourceBundle
ListResiourceBundle,
PropertyResourceBundle.


java.nio.charset.
java.util
EventListener, EventListenerProxy,
EventObject

JavaBeans (. ).
java.util.Scanner
.


java.util.regex.
java.util.concurrent
locks ,

(,

)
, ,

C# System.Threading.Timer

System.Threading.TimerCallback.

System.Timers System.
C#
ToString()
System.IFormatProvider.
,
System.IFormattable.
,
,
System.Globalization. CultureInfo,
System.Globalization. NumberFormatInfo
System.Globalization. DateTimeFormatInfo.
C#
System.Globalization
RegionInfo CultureInfo.



System.Resources.ResourceSet.



System.Text.

C#


System.Text.RegularExpressions
System.

System.Threading,
mscorlib,
System.

207

, (latches),
- .
java.util.concurrent.atomic
,

.
java.io File,
,

Reader InputStream,
,
Writer OutputStream,
.
java.nio

-.


System.IO.

java.nio

System.Runtime.Remoting.Channels
mscorlib System.Runtime.Remoting.
,
,

JavaBeans,
.NET,
java.beans.
System.ComponentModel.

, ,
(graphical user
System.
interface, GUI) Java.
GUI
(
System.Windows.Forms
)
System.Windows.Forms.
java.awt.

,


System.Drawing System.Drawing.
javax.swing.

Java
SWT
(Standard Widget Toolkit [15]),

Eclipse [16].


, System.Net
,
System.Runtime.Remoting
java.net, javax.net, java.rmi,
mscorlib System.
javax.rmi.

java.security, javax.crypto
System.Security
javax.security
mscorlib, System System.Security.

,
,

.
.NET
java.sql javax.sql
System.Data

,
System.Data.
208


JDBC (Java DataBase
Connectivity).
javax.naming
, JNDI
(Java Naming and Directory Interface) (.
).


ADO.NET.

ActiveDirectory on Microsoft

System.DirectoryServices
System.DirectoryServices
System.DirectoryServices.Protocols.

11
[1] J. Gosling, B. Joy, G. Steele, and G. Bracha. Java Language Specification, 3-rd edition. AddisonWesley Professional, 2005.
http://java.sun.com/docs/books/jls/download/langspec-3.0.pdf.
[2] C# Language Specification. Working Draft 2.7. ECMA, June 2004.
http://download.microsoft.com/download/8/1/6/81682478-4018-48fe-9e5ef87a44af3db9/standard.pdf.
[3] C# Langauge Specification 2.0, March 2005 Draft.
http://download.microsoft.com/download/8/1/6/81682478-4018-48fe-9e5ef87a44af3db9/CSharp%202.0%20Specification.do.
[4] . , . .
. .: , 1989.
[5] . . - . . .:
, 2004.
[6] JNI http://java.sun.com/j2se/1.5.0/docs/guide/jni/index.html.
[7] S. Liang. Java Native Interface: Programmers Guide and Specification. Addison-Wesley
Professional, 1999.
[8] JavaBeans http://java.sun.com/products/javabeans/index.jsp.
[9] JavaBeans Specification 1.01.
http://java.sun.com/products/javabeans/docs/spec.html.
[10] J2SE http://java.sun.com/j2se/1.5.0/docs/api/index.html.
[11] .NET http://www.msdn.microsoft.com/netframework/.
[12] Jakarta Commons http://jakarta.apache.org/commons/index.html.
[13] Apache Jakarta Project http://jakarta.apache.org/.
[14] Joda http://www.joda.org/.
[15] SWT http://www.eclipse.org/swt/.
[16] Eclipse http://www.eclipse.org/.

209

12.


.

.


, , , ,
, , , ,
, , , ,
, .



(software component)
. ,
.
( ),
, .
,
,
.
.
UML ,
, - ,
, - , .
, ,
, .
,
. ,
, - (component
based) , JavaBeans, EJB, CORBA, ActiveX, VBA, COM, DCOM,
.Net, Web- (web services), ,
. [1],
, ,
.
,
, , .
, ,
.


. (,
.) . ,
.

, ,
, , .
210


.

. .

. ,
.
.
, .
,
. ,
,
.

.
, , ,
, .
( )
.
, .
,
, .
, .

, .
, .

, ,
.
. -.
, .
, HTML-
, .
,
. ,
HTML-,
, ,
,
.

(.. ),
HTML-
.
,
. , , ,
,
, ,
. ,
, . ,

, ,
.
211

.
, ,
, ,
. . ,
, .
.
.

, .
,
.
, ,
.
,
.
, ,
,
(component model) [2].
, , .. ,

(, , , .)
.
.
, ,
,
.
,
(basic services). ,
, , , .
, , ,
,
.
, ,

( , component framework).
J2EE, .NET, CORBA.
J2EE, .NET CORBA
, .
, , -
,
. , ,
, ,
.
, ,
, . 65.
- .
o , ,
. , ,
.
o .
, , , ,
,
.
212

o , .

.

65. .

, .

. ,
.

. , ,
,
,
.
, , ,
20 ,
. ,
,
,
.
-, , ,
.
. ,
.

, .

213



. ,
,
. , ,
.

. J2EE .NET ,
, - ,
. ,

.
, ,
.
(transparency).

,
, (.. ) ,
,
, .

, ,
,
, ,
, .
, ,
, . ,
,
Web-
,
.
(openness).

, .
, , ,
, .
.
,
.
,
,
.

.
(scalability).

,
.
, , , ,
, , ,
.
, ,
214

.
, ,
, (
, )
, , . , ,
, ,
, .
, ,
, .

,
.
(
, )

. .
o
.
o
.
o :
;
;
, .
o , ,
.
o ,
.
,
.

.
,
,
.
- (peer-to-peer, P2P)
.
(safety).
,
,
, ,
.
,
.
.
o .

(..
, ) , ..
, .
, ,
215

,

.
,
, , ,

.
o .
,
-,
,
, .
,

.
o .

. ,
,
,
. ,
,
.
.
.
,
(
).
(persistent)
.
, ,
.
. - ,
[3].
.
.
.
o .
o
.
o .
, ,
.
,
.
o , , , ()
, .
o ,
-, .
,
.
216

.
.
o .
o ,
- .
o ,
.
o
, .
, , , .
.
.
o .
o , ,
, .
o ,
.
.
.
o , ,
.
o ,
.
o ,
, .
.
.
o .
o .
,
, .
o , ,

.
.
.
o .
o .
o
.
o
.
.
.
o .
, ,
,
217

,
.
o .
o

.
o ,
.

,
. ,
(middleware, ,
, ,
),
.



, .. , , ,
, , .
.
,
.
.
(synchronous) ,
, ,
.
(blocking).

.

66. .

,
. ,
, ,
,
. ,
, ,
, , .
218


.

. :
, , ,
.
, ,
, ,
.


(Remote Procedure Call, RPC, -,
,
). -
(Remote Method Invocation, RMI).
,
.
,
. (Interface
Definition Language, IDL),
, ,
.
IDL
,
(, C/C++),
(client stub server stub).
, ,
-. ,
.
.
IDL-

IDL

67. , RPC.

1. ,
. (binding) .
, .
2. ,
(. ).
(marshaling).
219

3. ( , serialization)
- , ,
, .
4. ,
.

.
, -.
, ,
,
(deserialization) (unmarshaling),
, ,
.

.
, ,
, , , .
,
.
, ,
. ,
, , ,
, ,
. ,
.
,
.
,

68. .

220

-
. .
-
.
,
. , , ,

.
RMI (skeleton)
.
.
,

.
, .
o , ,

.
,
.
o , ,
, , .
,
, ..
.
(asynchronous) (non blocking)
,
.
.

, ,
.


,

,

69. .



.
, , ,
, .
221

, , ,
.
.

, , ,
.
.
, .
, ,
, . , ,
, ,
.

70. .

.
, ,
. , ,
, , .
,
, , .
,
.

(
) , .
, ,
.
.
, , ,
, .
.
,
, .
, ,
.
.
, .
(atomicity).
, .
.
222

(consistency).
.
(isolation).
. , , ,
, .

. ,
.
(durability).
.
, .
, ACID.
ACID (flat
transactions), .
,
; , , ,
.
,
( !).
,
, , ,
.

(transaction monitors),
.
, .

71. .

,

. ,
223

, (commit), ,
(rollback), .

,
. ( )
. ,
,
, .
, .

.
,
, ,
.
(Two-phase Commit Protocol, 2PC) [3,4],
.
1. -
.
2. ,
.
.
3. ,
,
.
,
.
4. , ,
, .
, .
, ,
JavaBeans ,
- [5,6].
vetoableChange()
java.beans.VetoableChangeListener.
java.beans.PropertyVetoException,
, . ,
, , propertyChange()
java.beans.PropertyChangeListener.

12
[1] C. Szyperski. Component Software Beyond Object-Oriented Programming. Boston, MA:
Addison-Wesley and ACM Press, 1998.
[2] F. Bachmann, L. Bass, C. Buhman, S. Comella-Dorda, F. Long, J. Robert, R. Seacord,
K. Wallnau. Volume II: Technical Concepts of Component-Based Software Engineering, 2nd
Edition/ Technical Report CMU/SEI-2000-TR-008.
http://www.sei.cmu.edu/pub/documents/00.reports/pdf/00tr008.pdf.
[3] . , . . . . .:
, 2003.
[4] G. Alonso, F. Casati, H. Kuno, V. Machiraju. Web Services. Concepts, Architectures and
Applications. Springer-Verlag, 2004.
[5] JavaBeans Specification 1.01.
http://java.sun.com/products/javabeans/docs/spec.html.
224

[6] J2SE http://java.sun.com/j2se/1.5.0/docs/api/index.html.


[7] D. Schmidt, M. Stal, H. Rohnert, F. Buschmann. Pattern-Oriented Software Architecture.
Volume 2. Patterns for Concurrent and Networked Objects. Wiley, 2000.

225

13. Web-

Java 2 Enterprise Edition .NET.


,
Web-.


Web-, XML, XSLT, XML, Web, EJB-, Web- J2EE, EJB, ,
Java RMI, JMS, JNDI, JTA, , DOM, SAX, StAX, ADO.NET, ASP.NET,
.NET, .NET Remoting, Active Directory, .


Web-
,
,
.

.
, , ,
. , , ,
.
, , ,
.
(TCP/IP HTTP)
HTML, ,

. ,
,
, ..

,
.
, Web-, .. ,
, HTML ,
. ,
, Web-,
,
, .

(Extensible Markup Language, XML) . XML

.
Web-
,
, . XML
.
Web-
XML, .
226

XML
XML,
. [1-7].
XML [3-5] : XML-
<tag>
</tag>. tag ,
, -, (-)
. , .
, ,
, .
. , ,
<tag />, .. .
XML.
<book
title = "Pattern-Oriented Software Architecture, Volume 1: A System of Patterns"
ISBN = "047195869"
year = 1996
hardcover = true
pages = 476
language = "English">
<author>Frank Buschmann</author>
<author>Regine Meunier</author>
<author>Hans Rohnert</author>
<author>Peter Sommerlad</author>
<author>Michael Stal</author>
<publisher
title = "John Wiley & Sons"
address = "605 Third Avenue, New York, NY 10158-0012, USA" />
</book>

<book>, , <author>
<publisher>, ( ) .
title, ISBN, year, hardcover, pages language ( ,
, .. International Standard Book Number ISBN,
, , ). <publisher>, ,
title address ( ).
XML-, ,
.NET,
. ,
, , , .
XML ,
. ,
, XML, DTD (Document
Type Declaration, ) [3-5] XMLSchema [6].
XML- , XML,
, . UTF8.
, ,
, ,
. DTD XMLSchema. ,
, ,
DTD XML
. ,
,
(Unified Resource Identifier, URI),
, .
227


EJB (. ).
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1
EJB 2.1//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_2_1-1.dtd">
<sun-ejb-jar>

</sun-ejb-jar>

DocBook XML
, HTML, PDF
.
<?xml version="1.0" encoding="windows-1251"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
<article>

</article>

, XML-
, <!-- -->, <?
processor-name ?> ( processor-name ,
) CDATA,
<![CDATA[, ]]>.
, .

11.

XML

<
>
&
"
'

&lt;
&gt;
&amp;
&quot;
&apos;

11. XML.

XML , ,
. ,
, [1-7].

Java 2 Enterprise Edition


J2EE Web 4 [8].
Enterprise JavaBeans (EJB).
EJB -
. , Java,
(bean, ,
). Enterprise JavaBean ,
EJB-, .
EJB.
o ,
.
o .
o
EJB .
228

o ,

.
o (
--)
: , ;
;
; ,
, , .
EJB-
(object transaction monitor) ,
-
.
Web- (Web components).

, , HTTP.
(WebUI),
,
, HTTP.
Web- (filters), Web- (web event
listeners), (servlets) Java (JavaServer Pages, JSP).
Web- Web-,
J2EE. Web-
,
, ,
,
.
Java.
J2EE J2SE Java
. , J2SE,
Web- EJB, , ,
HTTP.
(applets).
,
Web-.
,
HTML, Web-,
, HTTP.

Java, (deployment descriptor)
XML ,
. .
,
, ,
.
J2EE Web-.
, HTML-
, HTTP- Web-. Web-
Web-,
EJB. EJB
Web- HTML-,
229

, . ,
, HTML.

Web-
HTML

Web-

HTTP

Web-

JSP

Java

EJB-
EJB

()

72. J2EE .
, .

, J2EE
.
.
, .
o , ,
Web-.
o - EJB .
o
(). ,
J2EE (J2EE service provider interface,
J2EE SPI).
.
,
,
.
-- (MVC).

MVC. Web- ,
JSP , EJB .
, [9]
J2EE.

, ,
J2EE, , :
Java (Java RMI),
Java (Java message service, JMS).

230

Java RMI [10] .


Java
java.rmi .
, ,
, (remote interface)
java.rmi.Remote. , ,
.
. - ,
, .
, , ,
java.rmi.server.RemoteObject. hashCode(), equals()
toString(), ,
, . ,
java.rmi.server.UnicastRemoteObject java.rmi.activation.Activatable.
,
TCP, ,
RMI ( Java RMI).
(activatable objects),
- -
. ,
, .
(remote method), .. ,
,
java.rmi.RemoteException java.io.IOException
java.lang.Exception. ,
, ,
RMI.
, ,
.
- , ,
.

.
.
java.io.Serializable .
Java , RMI, .
.
package examples.rmi;
public interface Hello extends java.rmi.Remote
{
public String hello() throws java.rmi.RemoteException;
}

.
package examples.rmi;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
public class HelloImpl extends UnicastRemoteObject implements Hello
{
public static final String ServerHost = "hostname";
public static final String ServerURL = "rmi://" + ServerHost + ":2001/SERVER";

231

public static final int RegistryPort = 2000;


public HelloImpl () throws java.rmi.RemoteException { }
public String hello () throws java.rmi.RemoteException
{ return "Hello!"; }

public static void main (String[] args)


{
try
{
Hello stub = new HelloImpl();
Registry registry = LocateRegistry.getRegistry(RegistryPort);
registry.rebind(ServerURL, stub);
}
catch (Exception e)
{
System.out.println("server creation exception");
e.printStackTrace();
}
}

-.
package examples.rmi;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class HelloClient
{
public HelloClient () { }

public static void main (String[] args)


{
try
{
Registry registry = LocateRegistry.getRegistry
(HelloImpl.ServerHost, HelloImpl.RegistryPort);
Hello stub = (Hello) registry.lookup(HelloImpl.ServerURL);
System.out.println("response: " + stub.hello());
}
catch (Exception e)
{
System.err.println("Client exception: " + e.toString());
e.printStackTrace();
}
}

, .
1. . -
ServerHost ,
.
2. Java RMI,
Java.
rmic examples.rmi.HelloImpl

3. RMI ,
HelloImpl.
2000.
start rmiregistry 2000 &

4. .
java examples.rmi.HelloImpl

232

5. .
java examples.rmi.HelloClient

, 2000 2001 ,
.
response: Hello!

EJB java.rmi.Remote,

.
Java (JMS) [11]
( , )
J2EE. javax.jms J2SE.
JMS J2EE.
JMS .

. - javax.jms.Message.
, (map) ,
, , Java.
Message.
(headers),
.
, ,
, .
, JMS.
javax.jms.Connection,
(
javax.jms.ConnectionFactory), .
- (
javax.jms.Destination), .
JMS - (peer-to-peer, P2P),
/. JMS (,
, , .)
.
.

J2EE J2SE
JNDI (Java Naming and Directory Interface, Java
) [12].
JNDI javax.namimg
javax.naming.directory, javax.naming.event, javax.naming.ldap.
,
, .
javax.naming.Context, , javax.naming.InitialContext,
javax.naming.directory.InitialDirContext, javax.naming.ldap.InitialLdapContext.
(void bind(String, Object),
void rebind(String, Object) ,
), (Object lookup (String)),
(void unbind(String)) .
InitialDirContext InitialLdapContext
DirContext.
void bind(String, Object, Attributes) , Attributes
getAttributes(String)
233

NamingEnumeration<SearchResult> search(String, Attributes)

.
InitialLdapContext
(Lightweight Directory Access Protocol, LDAP).
JNDI
JNDI , jndi.properties,
, classpath.
JNDI , Java
, :

java.naming.factory.initial (
Context.INITIAL_CONTEXT_FACTORY)

, ;

java.naming.provider.url ( Context.PROVIDER_URL) URL

java.naming.dns.url ( Context.DNS_URL) URL


DNS , JNDI URL;

java.naming.applet ( Context.APPLET) -,

JNDI ;

java.naming.language ( Context.LANGUAGE) ,
, (: en-US,
fr, ja-JP-kanji). RFC 1766 [13].

JNDI c:/tmp.
JNDI
Sun [14].
package examples.jndi;
import java.util.Properties;
import
import
import
import
import

javax.naming.Binding;
javax.naming.Context;
javax.naming.InitialContext;
javax.naming.NamingEnumeration;
javax.naming.NamingException;

public class JNDIExample


{
public static void main (String[] args)
{
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory");
env.put(Context.PROVIDER_URL, "file://c:/tmp");
try
{
Context cntx = new InitialContext(env);
NamingEnumeration list = cntx.listBindings("");
while(list.hasMore())
{
Binding bnd = (Binding)list.next();
System.out.println(bnd.getName());
}

}
catch (NamingException e) { e.printStackTrace(); }

234


J2EE
Web- EJB- .
J2EE- .
, Web-
EJB, (synchronized).
J2EE-, ,
, ,
.

J2EE
.
EJB-, EJB ,
. ,
Java (Java Transaction API, JTA).
JTA javax.transaction. javax.transaction.xa.
, , TransactionManager,
Transaction UserTransaction Synchronization,
.
TransactionManager ,
, ,
Transaction. Transaction
, ,
,
.
javax.transaction.xa.XAResource. UserTransaction

, TransactionManager.
, EJB- (
, , container managed transactions),
, EJB-
(transaction attributes) .
.

Required

, , .
, ,
,
.
.

RequiresNew

, ,
. , , .

Mandatory

, , ,
.
TransactionRequiredException.

NotSupported

, ,
. , .
235

Supports

, ;
, .

Never


RemoteException. , .
,
javax.ejb.EJBException setRollbackOnly()
javax.ejb.EJBContext.

J2EE ,
, , .
,
J2EE.

J2EE .
, ..
. .
.
o .
o HTTP.
HTTP ,
Web-. ,
.
o (digest). ,
HTTP,
. .
o . ,
(
, , , - ), ,
, .
o .
HTTPS. ,
X.509 .
,
.
HTTP (Secure
Socket Layer, SSL, HTTP SSL
HTTPS).
,
CONFIDENTIAL / INTEGRAL .
, , ,
, .
, ,
, .. , -
.
C , Web EJB- ,
. ,
236


.
J2EE-
,
.
,
(URI) URI.

( )
URI.
,
, .
isUserInRole() getUserPrincipal()
HTTPServletRequest, Web, isCallerInRole() getCallerPrincipal()
EJBContext, EJB.

XML
XML-,
Web- XML.
, XML-,
XML-.
XML- javax.xml , org.w3c.dom
org.xml.sax, a .
.

XML javax.xml.parsers.
XML (Simple API for
XML, SAX) [15] (Document Object Model, DOM) [16].
W3C.

XML (SAX) [15] org.xml.sax.


, , XML-, ,
XML-
. XML-
,
org.xml.sax.ContentHandler.
(DOM) [16] XML, . Java-
org.w3c.dom. JDOM [17],
dom4j [18] Java,
DOM .
XML-
(Extensible Stylesheet Language Transformations,
XLST) [19]. XSLT-,
XSLT (XSLT-)
XML-. XSLT
javax.xml.transform. XSLT- Saxon [20]
Xalan [21].
J2EE 5.0, 2006 ,
XML- (Streaming API for XML, StAX).
XML- ,

237

(pull-), SAX,
, (push-).
XML- StAX , SAX,
.
StAX [22] .

.NET
.NET , J2EE.
, Web-,
J2EE.
.NET J2EE. Web-
, ASP.NET, EJB,
, ADO.NET. .NET
. ,
ASP.NET , ,
.NET Web-,
ASP.NET, . , ,
, J2EE, ,
. ASP.NET, Web-
J2EE, .
, Web- .NET
, . 73.
Web-
(Microsoft Internet
Information Services)

Web-
HTML

.NET

HTTP

ASP.NET

.NET

()

73. Web- .NET.

, Web- .NET ,
J2EE-.
.NET- .NET-
,
XML.
.

.NET Remoting,
RMI, .
, Remoting,
System.Rutime.Remoting , mscorlib System.Rutime.Remoting.
Remoting , ,
, (marshal-by-value)
(marshal-by-reference).

238

, ,
System.Runtime.Serialization.ISerializable
System.SerializableAttribute. .NET ,

. ,
, , .
, , System.MarshalByRefObject.
(
, . ) ,
.NET (proxy).

System.ContextBoundObject. ,
,
. .
.NET ,
.
Remoting ,
, , Java RMI.
, .
using System;
namespace Examples.Remoting
{
public class Hello : MarshalByRefObject
{
public String HelloMethod() { return "Hello!"; }
}
}

, .
using System;
using System.Runtime.Remoting;
namespace Examples.Remoting
{
public class HelloImpl
{
public static void Main()
{
RemotingConfiguration.Configure("RemotingServer.exe.config");
Console.ReadLine();
}
}
}

.
using System;
using System.Runtime.Remoting;
namespace Examples.Remoting
{
public class HelloClient
{
public static void Main()
{
RemotingConfiguration.Configure("RemotingClient.exe.config");
Hello stub = new Hello();
Console.WriteLine("response: " + stub.HelloMethod());
}
}
}

239

,
. .
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown
mode = "Singleton"
type = "Examples.Remoting.Hello, Hello"
objectUri = "MessageServer"
/>
</service>
<channels>
<channel ref = "http" port = "8989" />
</channels>
</application>
</system.runtime.remoting>
</configuration>

.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<client>
<wellknown
type = "Examples.Remoting.Hello, Hello"
url = "http://hostname:8989/MessageServer"
/>
</client>
</application>
</system.runtime.remoting>
</configuration>

, .
(,
Hello.cs, Server.cs Client.cs).
csc.exe /noconfig /t:library Hello.cs
csc.exe /noconfig /r:Hello.dll Server.cs
csc.exe /noconfig /r:Hello.dll Client.cs

,
Hello. ,
.

Server.exe


Client.exe, Hello.dll, RemotingClient.exe.config, hostname URL
, ,

Client.exe

, 8989 ,
.
response: Hello!


( , ,
),
(HTTP TCP), .

240

.NET
.NET ,
Remoting System.Messaging.
ASP.NET ,
.

Remoting ,
.NET
.
, , ,
.
, /
. .NET Active Directory.
, .NET, .NET ,
Active Directory.
System.DirectoryServices ,
System.DirectoryServices System.DirectoryServices.Protocols.
Active Directory
System.DirectoryServices.DirectoryEntry. C
.

System.DirectoryServices.DirectorySearcher.
Active Directory ,
LDAP.


, .NET
(application domains), , , , ,
.
.
, Remoting. .NET
, .
.NET-

.
,
.
Web-
.NET ,
System.AppDomain,
.

.NET , J2EE, ,
. .NET
Microsoft (Microsoft Transaction Server, MTS),
COM+.
System.EnterpriseServices, .

, System.EnterpriseServices.TransactionAttribute.
Required, RequiresNew, NotSupported, Supported Disabled.
241

, J2EE. Supported Supports


J2EE. Disabled ,
.
ASP.NET
, , Disabled,
Required.
, ,
System.EnterpriseServices.ServicedComponent, ,
, ,
COM+.

.

System.EnterpriseServices.AutoCompleteAttribute
,
.
, .

SetComplete() SetAbort() System.EnterpriseServices.ContextUtil



.

ADO.NET System.Data.Common.DbConnection
System.Data.Common.DbTransaction.
System.Messaging.MessageQueueTransaction.

, J2EE, .NET-
,
.

.NET- ,
J2EE-.
, ,
,
,
. .NET
, ,
.

System.Security,
mscorlib, System System.Security.

XML
XML- .NET
XML (DOM) , StAX,
System.Xml.XmlReader. , XML,
XML-, XSLT-,
System.Xml, System.Data,
System.Data.SqlXml System.Xml.

242

XML .NET
XML- ADO.NET (
) System.Xml.XmlDataDocument.

13
[1] Web- World Wide Web http://www.w3.org/.
[2] http://www.xml.com/.
[3] XML 1.1, 2004. http://www.w3.org/TR/xml11/.
[4] Annotated XML 1.0, 1998. http://www.xml.com/axml/axml.html.
[5] (XML) 1.0 ( ).
http://www.rol.ru/news/it/helpdesk/xml01.htm.
[6] XMLSchema http://www.w3.org/XML/Schema.
[7] Namespaces in XML, 1999. http://www.w3.org/TR/REC-xml-names/.
[8] Java Platform Enterprise Edition Specifications, version 1.4.
http://java.sun.com/j2ee/j2ee-1_4-fr-spec.pdf.
[9] . , . . . . .:
, 2003.
[10] Java RMI http://java.sun.com/j2se/1.5.0/docs/guide/rmi/index.html
[11] JMS API http://java.sun.com/products/jms/docs.html
[12] JNDI http://java.sun.com/j2se/1.5.0/docs/guide/jndi/index.html
[13] RFC 1766, http://rfc.net/rfc1766.html
[14] http://java.sun.com/products/jndi/serviceproviders.html
[15] Web- SAX http://www.saxproject.org/
[16] Web- DOM http://www.w3.org/DOM/
[17] Web- JDOM http://www.jdom.org/
[18] Web- dom4j http://www.dom4j.org/
[19] XSLT. http://www.w3.org/TR/xslt
[20] Web- Saxon http://www.saxonica.com/
[21] Web- Xalan http://xml.apache.org/xalan-j/
[22] Streaming API for XML http://www.jcp.org/en/jsr/detail?id=173
[23] B. McLaughlin. Java and XML, Second Edition. OReilly, 2001.
[24] J2EE http://java.sun.com/j2ee/1.4/docs/index.html
[25] .NET .NET Development MSDN,
http://msdn.microsoft.com/library/default.asp
[26] . , . , . , , . , . . J2EE.
-. .: , 2002.

243

14. Web- J2EE


.NET

Java Enterprise Edition .NET


Web-,
.


EJB, , , ,
, HTTP, Java, Java (JSP), Web- .NET.


Web-
Web-
J2EE .NET. ,
. 74.
: (WebUI)
.

Web-
HTML

Web-

HTTP

WebUI

()

74. Web- J2EE .NET.

Web-
HTML, , .
,
, .
,
J2EE .NET, .
J2EE EJB
, -, ..
.
.NET ,
- ,
. EJB 3.0.
EJB -
. ,
( ).
.NET-

. .NET
.

244

- J2EE
, J2EE -,
, Enterprise JavaBeans.
EJB 2.1,
2006 EJB 3.0 ( J2EE
5.0).
. , -
,
JDBC. , ,
- ,

. JTA
(. ).
Enterprise JavaBeans (EJB) , J2EE , .
EJB
, . EJB
EJB-, . EJB .
EJB-, ,
,
, , .
EJB-, .
EJB-, ,
, .
.
EJB-
.
.
:
.
EJB , -,
Java,
, ,
-, XML-, .
EJB- .
Java, .
.
, ,
.
.
, .
EJB . EJB.
(, entity beans).
.
(session beans).

, -.
245

, (message driven beans).


-. ,
, ,
, . ,
, , .
, ,
, .
EJB .
[1,2].


:
;

; , ; ,
, .
.
.
(remote interface).
, ,
.. , .
javax.ejb.EJBObject (
, java.rmi.Remote).
( JavaBeans, ..
Type getName()/void setName(Type)),
, .
, -
, . ,
,
, .

- ,
.
(local interface).
,
, .
,
.
,
. ,
EJB, .
javax.ejb.EJBLocalObject.
(remote home interface).
.

findByPrimaryKey()
create(). ,
,
. , ,
, , createByTitle(String
title), , Collection
246

findByAuthors(Collection authors).

, .
.
javax.ejb.EJBHome (
java.rmi.Remote).
(local home interface).
, ,
. ,

.
javax.ejb.EJBLocalHome.
(bean class).
(
!).
.
,
javax.ejb.EntityBean. ,
,
getName()/setName(). EJB-
. ,
, .
,
javax.ejb.SessionBean
.
, ( )
, EJB-
.
,
ejbCreate().
. ,
.
null .
void, - ,
.
createSomeSuffix()
ejbCreateSomeSuffix() .
, void.
,
,
(javax.ejb.EntityBean javax.ejb.SessionBean). , , ejbActivate()
ejbPassivate(), ;
ejbRemove(), ;
ejbStore() ejbLoad(),
.
. 75.
,

, .
.
,
.

247

Class.newInstance()
setEntityContext()

Object.finalize ()
unsetEntityContext()


ejbCreate()
ejbPostCreate()

ejbPassivate()

ejbRemove()

ejbActivate()

ejbLoad()

ejbStore()
75. EJB .

. 76.
ejbCreate()
.

ejbRemove()

Class.newInstance()
setSessionContext()
ejbCreate()

ejbPassivate()

ejbActivate()

76. .

.
. 77.
(primary key class).
,
.
, ,
.
, , String Integer.
, , ..
248

.
equals() hashCode(), EJB-

. java.io.Serializable.

Class.newInstance()
setSessionContext()
ejbCreate()

ejbRemove()


77. .


, , . 78.
, , , ,
(, ). ID,
. Book PublisherID,
.
Book

Publisher

ID : int
Title : String
ISBN : String
PublisherID : int

ID : int
Title : String

78. .

,
EJB-.
package ru.msu.cmc.prtech.examples;
import java.rmi.RemoteException;
import java.util.Collection;
import javax.ejb.EJBObject;
public interface PublisherRemote extends EJBObject
{
public String getTitle ()
throws RemoteException;
public void
setTitle (String title) throws RemoteException;
public Collection getBooks ()throws RemoteException;
public void
setBooks (Collection books)
throws RemoteException;
public void addBook
(String title, String isbn)
throws RemoteException;
public void removeBook (String title, String isbn)
throws RemoteException;
}

249

package ru.msu.cmc.prtech.examples;
import java.rmi.RemoteException;
import javax.ejb.EJBObject;
public interface BookRemote extends EJBObject
{
public String getTitle ()
throws RemoteException;
public void
setTitle (String title) throws RemoteException;
public String getISBN ()
throws RemoteException;
public void
setISBN (String isbn) throws RemoteException;
public PublisherRemote getPublisher () throws RemoteException;
public void
setPublisher (PublisherRemote publisher)
throws RemoteException;
}

.
package ru.msu.cmc.prtech.examples;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
import javax.ejb.FinderException;
public interface PublisherHomeRemote extends EJBHome
{
public PublisherRemote create (Integer id)
throws CreateException, RemoteException;
public PublisherRemote findByPK (Integer id)
throws FinderException, RemoteException;
}
package ru.msu.cmc.prtech.examples;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
import javax.ejb.FinderException;
public interface BookHomeRemote extends EJBHome
{
public BookRemote create (Integer id)
throws CreateException, RemoteException;
public BookRemote createBook (String title, String isbn)
throws CreateException, RemoteException;
public BookRemote findByPK (Integer id)
throws FinderException, RemoteException;
}

. , ,
,
.
package ru.msu.cmc.prtech.examples;
import java.util.Collection;
import java.util.Iterator;

250

import
import
import
import
import

java.rmi.RemoteException;
javax.ejb.CreateException;
javax.ejb.EntityBean;
javax.naming.InitialContext;
javax.naming.NamingException;

public abstract class PublisherBean implements EntityBean


{
public Integer ejbCreate (Integer pk)
{
setId(pk);
return null;
}
public void ejbPostCreate (Integer pk) { }
public abstract Integer getId ();
public abstract void
setId (Integer pk);
public abstract String getTitle ();
public abstract void
setTitle (String title);
public abstract Collection getBooks ();
public abstract void
setBooks (Collection books);
public void addBook (String title, String isbn)
{
try
{
InitialContext context = new InitialContext();
BookHomeRemote bookHome =
(BookHomeRemote)context.lookup("BookHomeRemote");
BookRemote book = bookHome.createBook(title, isbn);
Collection books = getBooks();
books.add(book);

}
catch (NamingException e) { e.printStackTrace(); }
catch (CreateException e) { e.printStackTrace(); }
catch (RemoteException e) { e.printStackTrace(); }
}
public void removeBook (String title, String isbn)
{
Collection books = getBooks();
Iterator it = books.iterator();
try
{
while(it.hasNext())
{
BookRemote book = (BookRemote)it.next();
if(
book.getTitle().equals(title)
&& book.getISBN().equals(isbn)
)
{
it.remove();
break;
}
}
}
catch (RemoteException e) { e.printStackTrace(); }
}

251

package ru.msu.cmc.prtech.examples;
import javax.ejb.EntityBean;
public abstract class BookBean implements EntityBean
{
public Integer ejbCreate (Integer pk)
{
setId(pk);
return null;
}
public void ejbPostCreate (Integer pk) { }
public Integer ejbCreateBook (String title, String isbn)
{
setTitle(title);
setISBN(isbn);
return null;
}
public void ejbPostCreateBook (String title, String isbn) { }
public abstract Integer getId ();
public abstract void
setId (Integer pk);
public abstract String getTitle ();
public abstract void
setTitle (String title);
public abstract String getISBN ();
public abstract void
setISBN (String isbn);
public abstract PublisherRemote getOrganization ();
public abstract void
setOrganization (PublisherRemote pr);
}

,
, , ,
.
.
javax.jms.MessageListener.
EJB, ,
javax.ejb.MessageDrivenBean.
void onMessage(javax.jms.Message),
.
, void ejbCreate() void
ejbRemove() .
, ,
(. 77).
.
, , .
, ISBN
, .
package ru.msu.cmc.prtech.examples;
import
import
import
import
import

javax.ejb.EJBException;
javax.ejb.MessageDrivenBean;
javax.ejb.MessageDrivenContext;
javax.jms.MapMessage;
javax.jms.Message;

252

import
import
import
import

javax.jms.MessageListener;
javax.naming.Context;
javax.naming.InitialContext;
javax.naming.NamingException;

public class TransferProcessorBean


implements MessageDrivenBean, MessageListener
{
Context context;
public void setMessageDrivenContext (MessageDrivenContext mdc)
throws EJBException
{
try { context = new InitialContext(); }
catch (NamingException e) { throw new EJBException(e); }
}
public void ejbCreate() { }
public void onMessage (Message msg)
{
MapMessage message = (MapMessage)msg;
try
{
Integer publisherPK = (Integer)message.getObject("Publisher");
String title
= (String)message.getObject("Title");
String isbn
= (String)message.getObject("ISBN");
PublisherHomeRemote publisherHome =
(PublisherHomeRemote)context.lookup("PublisherHomeRemote ");
PublisherRemote publisher = publisherHome.findByPK(publisherPK);
publisher.addBook(title, isbn);
}
catch (Exception e) { throw new EJBException(e); }
}

public void ejbRemove () throws EJBException


{
try { context.close(); }
catch (NamingException e) { }
}

EJB
, EJB
XML ,
.
,
J2EE
(, NetBeans 4.0 [3]).
.
. [2].
-
JAR-. ,
J2EE .
,
, , .
EJB 2.1
.
253

<?xml version="1.0" encoding="UTF-8"?>


<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans
2.0//EN" http://java.sun.com/j2ee/dtds/ejb-jar_2_1.dtd">

<ejb-jar>

.
EJB ,
.

<enterprise-beans>

, <ejb-jar> .
EJB <entity>,
<session>, <message-driven>.

<entity> <session>

<enterprise-beans> , ,
.
.
o <ejb-name>
.
.
o <home>
, EJB 2.0. EJB 1.1 .
.
o <remote>
, EJB 2.0. EJB 1.1 .
.
o <local-home>
.
.
o <local>
.
.
o <ejb-class>
.
.
o <primkey-field>
, .
, (
).
o <prim-key-class>
, .
.
, java.lang.Object.
o <persistence-type>
, .
Bean Container, ,
.
o <cmp-version>
.
EJB, ,
. 2.x 1.x.
254

o <abstract-schema-name>
.

EJB QL,
, .
o <cmp-field>
, .
,
EJB . <description>
<field-name> . EJB 2.0
(
getName() setName()), EJB 1.1
.
o

<security-role-ref>

, .
, .
,
.
<description> () <role-name> (),
<role-link> (,
, <security-role> <assembly-descriptor>).
o

<security-identity>

.
,
. <runas><role-name></role-name></run-as>
, <use-caller-identity/> ,
.
o

<session-type>

, .
Stateful Stateless, ,
.
o

<transaction-type>

, .
Container Bean, ,
.
<assembly-descriptor>, . .
o

<query>

, .
,
, .
EJB QL [X]
<query-method>. CDATA
<ejb-ql>.

<query>
<query-method>
<method-name>findByName</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<ejb-ql>
<!CDATA[
SELECT OBJECT(c) FROM Client c WHERE c.name = ?1

255

]]
</ejb-ql>
</query>

<relationships>

. <ejb-jar>.
,
.
<ejb-relation>.
o <ejb-relation>
.
<ejb-relation-name>
, . .
<ejb-relationship-role>
. .
.
<ejb-relationship-role-name>.

.
<multiplicity> One Many.
, .
<relationship-role-source> <ejb-name>
, .
, ,
. <cmr-field>,
<cmr-field-name>,
.

<assembly-descriptor>

<ejb-jar>
, .
o <container-transaction>
, .
<description>, .

. ,
EJB-, .
<method>
.
<ejb-name>, , <method-name>,
*,
.
<description>, <method-params> <methodintf>, Remote, Home, Local, Local-Home,
,

.
<trans-attribute>
.
,
.

,
256

,
.
NotSupported, Supports, Required, RequiresNew, Mandatory,
Never. .
o <security-role>
, .
, .
<role-name>, .
o <method-permission>
, .
, <security-role>,
.
<description>, <role-name>
<method> (. ), ,
<unchecked/>,
, .
<method> <ejb-name>, ,
<method-name>, *,
.
o <exclude-list>
.
<method> (. ), ,
.
.

.NET
.NET , , J2EE
EJB. - .NET-
, ,
EJB. ,
.NET EJB , ,
, (
).
ADO.NET [4],
.
ADO.NET System.Data (
System.Data.OracleClient System.Data.SqlXml) System.Data,
.
, ,
System.Data.DataSet. ,
.
System.Data.DataTable, System.Data.Relation,
System.Data.Constraint.
( System.Data.DataColumn).
-, System.Data.DataRow.
DataSet DataTable , ..
.
DataSet XML.
System.Xml.XmlDataDocument.

DataAdapter, DataReader, DbConnection, DbTransaction, DbCommand ,
(
257

Visual Studio .NET


ODBC, OleDB, MS SQL Server, Oracle).
System.Data.Common,
System.Data.
DataAdapter DataReader
DataSet. ,
, SQL- .
ADO.NET.
DbConnection connection = new SqlConnection("Data Source=localhost;" +
"Integrated Security=SSPI;Initial Catalog=DBCatalog");
DbCommand command = new SqlCommand("SELECT ID, Title, ISBN FROM Book",
connection);
DataAdapter adapter = new SqlDataAdapter();
Adapter.SelectCommand = command;
connection.Open();
DataSet dataset = new DataSet();
adapter.Fill(dataset, "Book");
connection.Close();

HTTP
, Web-
J2EE .NET, HTTP,
.
Web-
HTTP,
.
HTTP (Hypertext Transfer Protocol, )
,
. [5,6].
HTTP : .
HTTP ,
(Universal Resource Identifier, URI), ,
, , .
<Request> ::= GET <URI> CrLf
| <Method> <URI> <HTTP-Version> CrLf
<Req-Header>* ( <Data> )?
<Req-Header> ::= <Field> : <Value> CrLf
CrLf
::= '\r''\n'

HTTP .

GET

URI , ,
URI.
If-Modified-Since,
, .

POST

, URI.
, ,
.
URI.
258

HEAD, PUT, DELETE, LINK, UNLINK .



. , ,
.

From

e-mail , .
: From: webmaster@yandex.ru

Accept, Accept-Encoding, Accept-Charset Accept-Language

(,
, ) .
: Accept: text/plain, text/html, text/x-dvi; q=.8; mxb=100000; mxt=5.0

User-Agent

Referer

, .

If-Modified-Since

,
, .

Authorization

,
.

ChargeTo

, .

Pragma

, , .
.
GET /locate?keywords=HTTP+description HTTP/1.1
Date: Mon, 15 Dec 2004 12:18:15 GMT
Accept: image/gif, image/jpg, */*
Accept-Charset: iso-8859-1, *, utf-8
Accept-Language: en
Connection: keep-Alive
User-Agent: Mozilla/4.7 [en] (Win98; u)

1xx
2xx

-,

200
201

OK
Created

301
302

Moved Permanently
Moved Temporarily

400
401
403
404

Bad Request
Unauthorized
Forbidden
Not Found

500

Internal Server Error

3xx
4xx

5xx

12. HTTP .

259

HTTP- ,
, , .
<Response>

::= ( <Content> )?
| <HTTP-Version> <Code> <Explanation> CrLf
<Resp-Header>* ( <Content> )?
<Resp-Header> ::= <Field> : <Value> CrLf
CrLf
::= '\r''\n'

12.
.

Allowed


URI.

Public

Content-Length, Content-Type, Content-Encoding Content-Language


(,
), MIME-,
.

Date

Last-Modified

Expires

, .

URI

URI .

Title

Server

Retry-After

,
, .
HTTP-.
HTTP/1.0 200 OK
Content-Length: 2109
Content-Type: text/html
Expires: 0
Last-Modified: Thu, 08 Feb 2001 09:23:17 GMT
Server: Apache/1.3.12
<HTML> <HEAD> <TITLE> </TITLE> </HEAD>
<BODY>
</BODY>
</HTML>

J2EE
Web-,
J2EE, .NET, HTTP-, ,
HTTP-, HTML-
.
, HTML.
260

HTML
,
WebUI,
.
J2EE 1.4 WebUI (servlets)
Java (Java Server Pages, JSP) , ,
.
J2EE 5.0 Java (Java Server
Faces, JSF) WebUI.
Java, HTTP
. JSP
, HTML Java,
. Web- JSP
.
HTML Java JSP
, -.

Java- ,
javax.servlet javax.servlet.http, J2EE SDK.
, , ,
HTTP.
javax.servlet.http .

HttpServlet

, HTTP-.
, HTTP-,
void doGet(HttpServletRequest, HttpServletResponse),
GET-, void doPost(HttpServletRequest,
HttpServletResponse), POST-.
, .

HttpServletRequest HttpServletResponse ,

() HTTP- .
,
.

Cookie

, ,
.

HTTPSession

, HTTP. ,
.
J2EE , ,
, XML- web.xml.
Web- .war, .
zip-, .war , Web-
Web-.
Web- WEB-INF,
. WEB-INF classes
.class- , EJB- Java-, lib
261

.jar .zip , . web.xml


WEB_INF.
.
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc... Web Application 2.2.. EN"
http://java.sun.com/j2ee/dtds/web-app_2_2.dtd>

<web-app>.
, URL,
. .
<servlet>
<servlet-name>ServletName</servlet-name>
<servlet-class>com.company.deprtment.app.ServletClassName</servlet-class>
<description></description>
<init-param>
<param-name>ParameterName</param-name>
<param-value>ParameterValue</param-value>
<description></description>
</init-param>
</servlet>

String
getInitParameter(String) Enumeration getInitParametersNames()
ServletContext.
URL .
<servlet-mapping>
<servlet-name>ServletName</servlet-name>
<url-pattern>URL</url-pattern>
</servlet-mapping>

Java
Java [7,8] ,
HTML Java HTML-,
. , JSP
--,
J2EE. JSP HTML-, Java
.
Web- JSP .
JSP doGet(), HTML-
, Java-
,
.
JSP-
web.xml, , . JSP-
, HTML- ,
.
JSP-
J2EE SDK javax.servlet.jsp, javax.servlet.jsp.el,
javax.servlet.jsp.tagext.
JSP- HTML, JSP
, (tags, actions) .
JSP-
JSP-.
.
262

<%@ directive attribute1="value1" ... attributeN="valueN" %>.

JSP .
page
. .
.
o import = " "
Java- import .
o contentType = "MIME-[;charset= ]"
MIME .
text/html.
<% response.setContentType(MIME-); %> (. ).
o isThreadSafe = "true|false"
true ,
, .
.
o session = "true|false"
true HTTP-,
false , session
.
o autoFlush = "true|false"
.
o buffer = " KB|none"
.
o extends = " "
, JSP .
o errorPage = "url "
, ,
.
o isErrorPage = "true|false"

.
o language = "java"
,
. Java.
( .NET) ,
-, JVM.
include ( JSP )
. file,
, URL .
taglib
. uri, URI
, prefix, .
.
jsp, jspx, java,
javax, servlet, sun, sunw.
,
.
,
, , ,
263

taglib .
.
<tagprefix:tag attribute1="value1" attributeN="valueN" />

, jsp:param, jsp:attribute.
.
<tagprefix:tag attribute1="value1" attributeN="valueN">

( )
</tagprefix:tag>

jsp,
taglib, .
. .

jsp:include


. jsp:param
- .
page, URL , flush,
true false ,
.

jsp:useBean

.
,
.
.
o id = " "
, JSP.
.
o class = " "
.
o scope = "page|request|session|application"
.
o type = " "
.
, , .

jsp:setProperty, jsp:getProperty
.
name , , property
.
jsp:getProperty
( toString() ).
jsp:setProperty value,
, param, ,
. jsp:setProperty
property *,
, ,
.
jsp:forward

. URL
page. URL
JSP- (. ),
.
264

jsp:param
, .

jsp:plugin

JavaBean .
jsp:params. ,
jsp:plugin .
o type = "bean|applet"
.
o code = " ( .class)"
o codebase = " , "
, , JSP.
o name = " "
o archive = " ,
"
,
.
o align = "bottom|top|middle|left|right"

HTML-.
o height = " "
o width = " "
o hspace = " "
o vspace = " "
o jreversion = " JRE, "
1.1.

. core (
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix = "c"
%>), , Java.
, <c:set var="variable" value="value" />
value variable, <c:if test="expression"></c:if>
JSP, ,
expression true, <c:forEach var="variable"
items="collection"></c:forEach>
collection,
variable.
, , (.
), .
Java-. JSP-
Web-,
.
.
JSP-, .
JSP ,
. JSP- .
<%! Java %>
, ,
, .
265

.
<% Java %>
JSP-, -
(
). .
<% = Java %>
${ Java}
#{ Java}
.

, .
JSP <%-- --%>.
.
HTML- <!-- --> ,
HTML-.
jsp:useBean
, ,
, , .

request ( ServletRequest).

param ( Map).

response ( ServletResponse).

out ( PrintWriter).

session ( HttpSession).

application (ServletContext).

config (ServletConfig).

pageContext (javax.servlet.jsp.PageContext).

exception .
JSP ,
.
<%@ page import="java.util.Date, java.util.Iterator,
com.company.Client" %>
<jsp:useBean id="clients" class="com.company.ClientList"
scope="page" />
<jsp:useBean id="convertor" class="com.company.ExchangeRate"
scope="page" />
<html>
<head>
<title>Table of clients</title>
</head>
<body>
<h3 align="center">Table of clients</h3>
Created on <%= new Date() %> <br><br>
<table width="98%" border="1" cellspacing="1" cellpadding="1">
<tr>
<%!
private double dollarsToRubles(double m)
{
return m*convertor.getDollarToRubleRate(new Date());
}
%>
<th width="50%" scope="col">Client</th>
<th width="25%" scope="col">Balance, dollars</th>
<th width="25%" scope="col">Balance, rubles</th>

266

</tr>
<%
Iterator it = clients.getNumberOfClients().iterator();
while(it.hasNext())
{
Client lient = (Client)it.next();
%>
<tr>
<td> ${client.getFullName()} </td>
<td> ${client.getBalance()} </td>
<td> ${dollarsToRubles(client.getBalance())} </td>
</tr>
<%
}
%>
</table> <br><br>
<jsp: include page="footer.txt" flush= "true" />
</body>
</html>

.NET
Web- .NET
ASP.NET [9,10]
J2EE. .NET : ,
HTML (HTML server controls)
(Web Server Controls), HTTP (
Java), IHttpHandler IHttpAsyncHandler,
Web- (Web forms), Java.
WebUI .NET HTML-,
. System.Web
System.Web.UI, .
HTML- runat,
server. System.Web.UI.WebControls.Button
Web-.
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
<head>
<script language="C#" runat=server>
void OnButtonClick(object sender, EventArgs e)
{
Message.Text="Hello World!!";
}
</script>
</head>
<body>
<form runat="server">
<h3>Button Example</h3>
Click on the submit button.<br><br>
<asp:Button id="MyButton"
Text="Submit"
OnClick="OnButtonClick"
runat="server"/>
<p>
<asp:label id="Message" runat="server"/>
</form>
</body>
</html>

267

.NET ,
System.Web.IHttpHandler System.Web.IHttpAsyncHandler.

Web- Microsoft (Internet Server Application Program Interface,


ISAPI). ,
Web-.
.
void ProcessRequest (System.Web.HttpContext
context). , , , ,
, ,
.
IHttpAsyncHandler IAsyncResult BeginProcessRequest(
HttpContext context, AsyncCallback cb, object extraData) void EndProcessRequest(
IAsyncResult result). ,
.
Web- .NET Java.
, HTML, ,
.NET, , ,
JSP.
Web- , ,
Java, , JSP-,
(code render) (data binding expressions).
Web- , JSP: <%@
directive attribute1="value1" ... attributeN="valueN" %>. ,
JSP: Page, page JSP,
, Import, include, Control
, Register (), .
Web- <script> </script>.
runat server language,
, . src
URL , .
<% %>. JSP,
<%= %>. , JSP, <%-- -%>.
<%# expression %>
, .
.
.NET,
J2EE, XML-
Web-.
configuration. location,
, path .
location ASP.NET system.web, , ,
( , .
[11]).

authentication

mode
(Windows, Forms, Passport None), forms
, .

authorization

, HTTP-.
268

allow,
deny.

compilation

ASP.NET.

customErrors

URL,
.

globalization

httpHandlers


IHttpHandelr IHttpHandlerFactory.

pages

sessionState

14
[1] . -. Enterprise JavaBeans. .: -, 2002.
[2] Enterprise JavaBeans Specification, version 2.1.
http://java.sun.com/products/ejb/docs.html.
[3] NetBeans http://www.netbeans.org/.
[4] MSDN ADO.NET
http://msdn.microsoft.com/library/default.asp?url=/library/enus/cpguide/html/cpconaccessingdatawithadonet.asp.
[5] Hypertext Transfer Protocol HTTP/1.1. RFC 2616.
http://www.w3.org/Protocols/rfc2616/rfc2616.html.
[6] http://www.opennet.ru/docs/RUS/http/index.html
[7] JSP http://java.sun.com/products/jsp/docs.html.
[8] . . . Java JSP: . .: -, 2005.
[9] MSDN ASP.NET
http://msdn.microsoft.com/library/default.asp?url=/library/enus/cpguide/html/cpconintroductiontoasp.asp.
[10] . , . , . , . , . , . . ASP.NET 1.0
. .: , 2004.
[11] ASP.NET
http://msdn.microsoft.com/library/default.asp?url=/library/enus/cpgenref/html/gngrfASPNETConfigurationSectionSchema.asp.
[12] . , . , . , , . , . . J2EE.
-. .: , 2002.
[13] . . Microsoft.NET. .: , 2003.

269

15.

,
Web-.
Web-,
.


Struts, JSF, - , Hibernate, JDO, -
, Spring, Web-, SOA, WSDL, SOAP, UDDI.


, Web-,
, ,
,
. Web, , ,
.
.NET ,
J2EE 1.4.
J2EE ,

.
J2EE ,
Sun

. J2EE
,
Web- (Web application frameworks).
.NET Microsoft
, .
, , -
. , ,
J2EE.

J2EE

J2EE 1.4.
EJB
.
,
.
Java,

J2SE. ,
.

.
- - ,
, ,
270

- .

. ,
, ,
,
.
EJB,
, ,
.

.
( , )
.
,
HTML , ,
.
, , , . ,
, ,
, .
JSP-
. : ASP.NET
,
, , ,
, .
,
, Java-.
J2EE 5.0 [1].

Jakarta Struts
Jakarta Struts [2,3] , Web, ,
.

:
HTML ,
HTTP-;

;

;
,
.
J2EE, Struts Web --.
JSP-, . Struts
J2EE
, , JSP-,
.

271


Web-
HTML

Web-

HTTP

Web-
ActionServlet
RequestProcessor

JSP

()

79. Web- Struts.

Struts
(ActionServlet),
(action), . -
, , ( ),
, , , ,
, , ,
. .
org.apache.struts.action.Action Struts
ActionForward execute(ActionMapping, ActionForm, HttpServletRequest,
HttpServletResponse) .

execute()
org.apache.struts.action.ActionForm.
, ActionForm.
,
.
execute() , , ,
.

struts-config.xml XML, action-mappings.
action, .

path

URI,
.

type

name

.
from-bean,
form-beans. form-bean name,
272

, type, . ,
form-property, (
JavaBeans) name ( ) type ( ).
, Struts
Java, , ,
, JSP
HTML-.

Java Server Faces


Java Server Faces (JSF) [4,5] WebUI javax.faces
,
Java. C jsf/html
, jsf/core
, , .
WebUI Java Java Server Faces
Struts (Struts
), WebUI
. .
(,
, - ).
.

.
,
.
WebUI JSF
.

.
(
, , ,
.).
Java Server Face 1.2 5.0
J2EE [6].

. Hibernate

. EJB
,
.
.
-
(object-relation mappers, ORM),
,
() , ..
, .
Hibernate [7-9].
, Hibernate ,
Java ( ,
273

JavaBeans )
. - POJO (plain old
Java objects, Java-),
, EJB.

, ,
Java, ,
,
.
Authors

Books

BookAuthors

ID : int
FirstName : String
Surname : String

AuthorID : int
BookID : int

ID : int
Title : String
ISBN : String

80. .

, ,
. 80 ,
.
import java.util.Set;
import java.util.HashSet;
public class Author
{
private int id;
private String firstName;
private String surname;
private Set books = new HashSet();
public int getId ()
{ return this.id; }
private void setId (int id) { this.id = id;
}
public String getFirstName ()
{ return this.firstName;
}
public void setFirstName (String firstName) { this.firstName = firstName; }
public String getSurname ()
{ return this.surname;
}
public void
setSurname (String surname) { this.surname = surname; }
public Set getBooks ()
{ return this.books; }
public void setBooks (Set books) { this.books = books; }
}
public class Book
{
private int id;
private String title;
private String isbn;
private Set authors = new HashSet();
public int getId ()
{ return this.id; }
private void setId (int id) { this.id = id;
}
public String getIsbn ()
{ return this.isbn; }
public void
setIsbn (String isbn) { this.isbn = isbn; }

274

public String getTitle ()


{ return this.title; }
public void
setTitle (String title) { this.title = title; }
public Set getAuthors ()
{ return this.authors;
}
public void setAuthors (Set authors) { this.authors = authors; }
}


.
Author Authors,
Author.hbm.xml.
<hibernate-mapping>
<class name="Author" table="Authors">
<id name="id" column="ID">
<generator class="increment"/>
</id>
<property name="firstName" column="FirstName"/>
<property name="surname"/ column="Surname">
<set name="books" table="BookAuthors" inverse="true">
<key column="AuthorID"/>
<many-to-many column="BookID" class="Book"/>
</set>
</class>
</hibernate-mapping>

Book.hbm.xml,
Book Books.
<hibernate-mapping>
<class name="Book" table="Books">
<id name="id" column="ID">
<generator class="increment"/>
</id>
<property name="title" column="Title"/>
<property name="isbn"/ column="ISBN">
<set name="authors" table="BookAuthors" inverse="true">
<key column="BookID"/>
<many-to-many column="AuthorID" class="Author"/>
</set>
</class>
</hibernate-mapping>

Hibernate

, --.
, Hibernate
. ,
: - ,
- ,
- , - ,
.
Hibernate
, .. , , ,
.

Hibernate.
C NHibernate [7] Hibernate
.NET.

275

Java Data Objects


- ,
, Java Data Objects (JDO) [10,11].

Java, ,
, (
JDO javax.jdo.PersistenceManager).

.
,
, .
JDO Hibernate. ,
Java ,
,
Hibernate. ,

.
JDO
, SQL.
, JDO ORM
,
, ORM
, JDBC.

Enterprise Java Beans 3.0


, J2EE [6]
EJB EJB 3.0 [12].
EJB 3.0 EJB 2.1
, EJB.
,
Hibernate JDO. (Gavin King), Hibernate,
EJB 3.0.
,
-
. , .
,
Java 5.
: ;
; ;
, ;
. , .NET
, , .
XML-, Hibernate .
,
,
.
.

Spring
Spring [9,13-15]
Web-.
, Struts. Spring
276

- ,
Web-.
, Spring,
, Web-.
(inversion of
control) - (aspect-oriented programming, AOP).

- API, .
,
, .
,
,
. Spring
XML- springapp-servlet.xml. ,

JavaBeans.
(dependency
injection)
, , ( ,
, .)
.
.
EJB 3.0 .
@Resource Type object;
,
object .
-
, ,
,
.
, .
. AOP-
, AOP, ,
.
(advice),
(joinpoints), ,
(pointcuts).

.
,
.
, "get"
A value, 0.
Spring , ,
.
AOP Spring
, JDO Hibernate.
Spring,
, , Spring
.
,
277


, .

. Java
( Java 5)
, ,
. EJB 2.1 ,
java.lang.RuntimeException, java.lang.Error javax.ejb.EJBException,
.
.

(Spring- Struts) .

Ajax
Web-,
, Ajax [16,17]
Web- .
, Web-
, .. ,
- , .
,
HTML-.
Web- Web-
, .

.
, ,
, .
,
,
.
HTML-,
Web. ,
,
.
Ajax JavaScript,
, XML, HTML, .
Ajax, JavaScript-
, ,
,
.
, .
Ajax
. ,
,
. , ,
Web J2EE .NET.

278

Web-
J2EE .NET
Web- Web- (Web services) [18-22],
, .
(services) .
,
.
, ,
. .
,
, .
.
. ,
, .
,
.
.
, , - .
, ,
, - ,
.
,
, , .
, , ,
, (service oriented architecture, SOA).
Web-. Web ,
, .. SOAP
, WSDL
UDDI , .
, , Web-,
. Web- J2EE, .NET
.

Web-,

81. Web-.

279

Web- -
, .
(business-to-business, B2B) Web-
, ,
, , ,
, .
, Web-
, . Web-,
,
.
: - ,
,
.
Web-.
Web-, IBM 1990-
, . 81.
,
, Web- (
), . ,
Web- ,
, .
, , Web-.
, , , ,
.
.
,
XML, .

Web-
Web- WSDL ( ) Web Services
Description Language, Web- [23]. (
) (IDL),
. WSDL 1.1, 2006
2.0, .
Web- WSDL
. ,
,
. , .
,
.

<types>.
XML- XML Schema .

<message> ,
. ,
,
.
,
.
. :

280

, , -. WSDL 1.1 4 ,
WSDL 2.0 9 .
, WSDL 1.1 (port
types).

<binding> .
/
. .

<port> , ,
, , .

, <service> ,
.

Web- SOAP (Simple Object


Access Protocol, ) [24]. SOAP
OSI, .. ,
,
HTTP, HTTPS, TCP, SMTP.
SOAP XML. SOAP- .
(envelope) .
(header)
, .

,
.
(body) ,
,
. .
SOAP- .
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header>
<t:Transaction
xmlns:t="http://company.com/soap-headers/attrs"
SOAP-ENV:mustUnderstand="1">
5
</t:Transaction>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:GetLastTradePrice xmlns:m="http://company.com/web-services/trading">
<symbol>DEF</symbol>
</m:GetLastTradePrice>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

, SOAP
.

Web-
Web-, UDDI (Universal Description, Discovery
and Integration, , ) [25].
281

,
Web-. ,
Web-.
IBM, Microsoft, SAP, NTT. ,
Web-. ,
.
UDDI Web-.
XML-. .

businessEntity. ( ),

Web-. , (), , , , ..
() .

businessService. Web-, .

bindingTemplate. , ,
, , (tModels).

tModel (technical model). , ,

, ,
.
, UDDI ,
, ,
..

Web- ,
, Web-
. , Web-
, Web-
.


Web- (WSDL, SOAP UDDI)
Web-. ,

Web-.
Web-
WS-Coordination (Web Services Coordination) [18,26]. ,
,
Web-, .

WS-Transactions WS-BusinessActivity [18,26],
WS-Coordination.
,
Web- (web services
orchestration) [18]. BPEL (Business Process Execution Language,
-) [18,27]. ,
, ,
Web-.

Web-
.
, .
282


WS-Reliability [28], SOAP. WS-Reliability
, Web-.


, Web-, WSSecurity [18,29].
SOAP, ,
,
,
.

15
[1] Java Platform Enterprise Edition Specifications, version 5.
http://java.sun.com/j2ee/5.0/index.jsp.
[2] Web- Apache Struts http://struts.apache.org/.
[3] C. Cavaness. Programming Jakarta Struts. OReilly, 2002.
[4] Java Server Faces Specification, version 1.2.
http://java.sun.com/j2ee/javaserverfaces/download.html.
[5] H. Bergsten. JavaServer Faces. OReilly, 2004.
[6] J2EE 5.0. http://java.sun.com/javaee/5/javatech.html.
[7] Web- Hibernate http://www.hibernate.org/.
[8] C. Bauer, G. King. Hibernate in Action. Manning, 2004.
[9] B. A. Tate, J. Gehtland. Better, Faster, Lighter Java. OReilly, 2004.
[10] Web- JDO http://jdocentral.com/.
[11] D. Jordan, C. Russell. Java Data Objects. OReilly, 2003.
[12] Enterprise Java Beans 3.0.
http://java.sun.com/products/ejb/docs.html.
[13] Web- Spring http://www.springframework.org/.
[14] R. Johnson. Expert One-on-One J2EE Design and Development. Wrox, 2002.
[15] R. Johnson, J. Hoeller, A. Arendsen, T. Risberg, C. Sampaleanu. Professional Java Development
with the Spring Framework. Wiley, 2005.
[16] http://developer.mozilla.org/en/docs/Category:AJAX:Articles.
[17] D. Crane, E. Pascarello, D. James. Ajax in Action. Manning, 2005.
[18] G. Alonso, F. Casati, H. Kuno, V. Machiraju. Web Services. Concepts, Architectures and
Applications. Springer-Verlag, 2004.
http://www.inf.ethz.ch/personal/alonso/WebServicesBook.
[19] IBM, Web- SOA. http://www128.ibm.com/developerworks/webservices/.
[20] . . -. . .: , 2003.
[21] . , . , . . Java 2. 3:
, , JSP, Web-. .: , 2003.
[22] . , . -. web- .NET. .: BHV, 2003.
[23] WSDL 1.1 http://www.w3.org/TR/wsdl.
[24] SOAP 1.2 http://www.w3.org/TR/soap/.
[25] Web- OASIS UDDI http://www.uddi.org/.
[26] WS-Coordination, WS-Transactions WS-BusinessActivity.
http://www-128.ibm.com/developerworks/library/specification/ws-tx/.
[27] BPEL. http://www128.ibm.com/developerworks/library/specification/ws-bpel/.
283

[28] WS-Reliability. http://www.oasisopen.org/committees/tc_home.php?wg_abbrev=wsrm.


[29] WS-Security. http://www-128.ibm.com/developerworks/webservices/library/wssecure/.

284

16.

, .
, ,
.


, , , , ,
, , , , , ,
, , COCOMO II, , PERT, , , , ,
, , .



,
.
.
,
. :
, , .
, ,
, .
, ..
, ,
. , .

, .. , , ,
, .

.
,
, .
, , ,
- . ,
.


.
, :
; ;
; / ,
..
(
),
, , ,
, , .
--, ..
, ,
,
285

, , .
.
-
, ,
, ,
.
.
, ,
, .
,
, ,
,
. ,
,
, , , , ,

.
- ,
(. ).
, , .
.
. ,
,
.
, , ,
.
,
(
, ),
.

.
.
, , .

: ,
.
,
.

.
.
,
( 1500 .. ).
, ,
, .
,
.
.

,
(, -, ,
286

.), .
, . , ,
, .

, ,
.
.
, , , ..
,
, (
) .

, .
,
.
. .
o ,
, . ,
,
, . , ,
.
, ,
. .
.
-,

.
o .

, .
, ,
.
.
( ,
,
.), ,
. ( )
,
.
,
.
o , ,
, .
.
,
, .
o
. ,
, . ,
, , RUP, XP, Microsoft Solution Framework DSDM
(Dynamic Systems Development Method, ),
.
287


,
.
, ,
.

,
.
, . ,
,
,
. ,
, ,
.
, .
, , ,
, ,
.


, ,
,
,
, .

-

, , .. ,
.
[1].
.
,
, , - .
,
,
. .
, , ,
.
,
, .
. ,
,
.
.
.

.
,
,
.
. ,
.
288

,
. ,
.

.


.
.
.
.
, .
,
.
. .
, ,
.
,
.
. ,
. ,
, ,
.
, .
, ,
.
,
,

.



-
.
, , .
[2,3].
(). ,
.
, ,
.
,
.
,
,
.

-.
().
. ,

.
289

, ,
.
,
, ,
. ,

.
().
, , .
, , .
,
, ,
, .
,
.
(). ,

. ,
, ,
.
,
, ,
,
(,
).


, ,
(stakeholders)
, , , -
. .
. ,
.
,
, .
. , , ..
.
,
: ,
, , .
, .
. ,
, .
.
. ,
.
. ,
.
-. ,
.
.
290

. -,
. .
. ,
.
, , ,
..

82. .

. , ,
,
.
, -,
, , - ,
, , ,
.

.
, - .

. ( ,
), .
, ,
, ,

, , .
, ,
, .
, ,
.
, ,
, , ,
( ). ,

.

,
,
,
.
.
, (project
291

scope ,
, ,
), , ,
,
.
.
,
, . ,
,
,
, ,
.
.

, , ,
. ,
, ,
, .
.
, ,
, ,
,
,
, .
.

, ( ).

,
,
.
.
, , ,
, ,
, .
.
,
, .

,
.
,
, ,
, , ,
, .
.
,
. , , ,
.

292


(project scope)
. .

.
, ,
, ,
.
.
,
,
.
,
,
, , .
.
.
, ,
, .
,
,
, .
(work breakdown structure).
,
, , ,

.
.

83. , .

, ,
.
,
, .
293

,
.
,
,
(deliverables), ,
.
, , . 83.
, , . 84.
, ,
, , .
,
, .
, , ,
, , ,
, .

84. , .



.
.
, ,
.
, ,
, .
, , , , ,
, - .
, ,
, :
. ,


, .

,
. ,
294

. ,
, .
,
, ,
. , ,
,
(, COCOMO, ,
). ,
, . ,
.

(lines of code, LOC).
.
,
. ,
, ,
.
- .
, ,

. 5000 50000
1 -.
(functional
points, FP) [4,5].
.

85. .

, -
(), ,
, - .
( )
, , .
(
--).

. , ,

, [4,5]
. ,
, .
, ,
300
5-10 .
295

[6].
, , , ,
, .
, ,
.
, ..
,
, .
,
.
,
,
II (Constructive Cost Model II, COCOMO II) [7-9].
,
, .
, ,
, (Application
Composition Model). -

Effort = A*Size.
o Size , , ,
.
1 10 .
o A
,
4 50.
A = (100 - ( ))/.
,
, (Early
Design Model) .
( -):
Effort = A*(Size)B*ME + ( )
( ):
Time = T*EffortS(0.28+0.2*(B-1.01))*Sced.
o A 2.45, T 3.67.
o Size .
o B , :
B = 0.91 + 0.01*i=1..5Wi,
Wi 0 5:
W1 , (0)
(5);
W2 ,
(0) (5);
W3 , (0) (5),
80% ;
W4 , (0)
(5);
W5 , 0 5

CMM ( 2).
296

o ME ,
1 6:
;
;
;
;
;
;
.
o EffortS , Sced
.
, ,
(Post-Architecture Model).
( -):
Effort = A*(Kreq*Size)B*MP + ( )
, ( ):
Time = T*EffortS(0.28+0.2*(B-1.01))*Sced.
o Size = ( . ) + RSize,
RSize = ( . ) * (100 AT)/100 *
(AA + 0.4*DM + 0.3*CM + 0.3*IM + SU)/100
AT ;
AA , 0
8;
DM ;
CM ;
IM
;
SU , 10 ,
, 50 ; 0, CM = DM = 0.
o , Kreq MP, , .
o Kreq (1 + ( , -
)/100).
o MP 17- ,
1 6:
;
;
;
;
;
;
;
;
;
;
;
;
;
297

;
;
;
.
, , ,
, .


,
, .

,
, ,
.
.
,
. ,
, .
XP
, .
,
, , ,
.
,
. : - (
), - (
), - -.
,
, ,
.
, ,
-.
T1
T2

T3

T4

T6
T7

T8
T9

T10

T5
T11

T12

T13

T14

T15

T16
T17

86. .

,
, . 86. ,
, 13.
298

T1
T2
T3
T4
T5
T6
T7
T8
T9
T10
T11
T12
T13
T14
T15
T16
T17

,
0.6
3.0
6.0
0.6
0.3
3.0
6.0
0.6
1.0
1.0
3.0
2.0
8.0
4.0
4.0
1.5
2.0

,
0.3
1.0
2.0
0.3
0.3
1.0
2.0
0.3
0.3
0.3
1.0
1.0
2.0
1.0
1.0
0.5
0.5

13. , . 86.

, -
( ),
PERT- (PERT program evaluation and review technique,
). PERT-,
, . 87.
, , PERT-.
T6
T1

T2

T3

T8

T4
T7
T5

T16
T9

T10
T11

T14

T13
T12

T15
T17

87. PERT- .

PERT-

, .
, . 87 ,
, . , ,
, .
.
, 10.7 . ,
, ,
, , .

.
, , .

, .

299

88. .

(Gantt chart).
, .
. 88.
4 : , ,
.

,
, , ,
.
(
)
(, .). ,
,
.

89. , .

, , ,
.
.
,
.
.
, , , ,
300

, ,
, . 89.
, 0.5 .
, .
, , ,
.,
.

, , ,
, .
,
, .
, .
,
, ,
.


, ,
, , ,
. - ,
, , ,
, , . ,
, , !, ,
.
.
,
.
.

.
,
,
, , , -
. [10,11]
,
10 ,
, .
,
, . , ,
,
, . ,
, . , , , ,
.


.

.
, -
. ,
301

,
. (,
, , )
,
.
.


. ,
, .
,
, , . , ,
,
.
,
.
,
, , ,
[10].

max

90. .

.
,
. ,
.

.
.

,
.
, -
. ,
- . ,
, .
, ,
.
,
, .

. ,
. ,
302

, ,
.
,
, ,
. ,
,
, ,
. ,
, .
.
.
, ,

.
, , ,
(Maslow) [12], . 91.




91. .


,
.

, -
.
, ,
. ,
,
, . ,
, .

, ,
, ,
( ).
.
o 3 [6]:
, ,
;
,
;
,
, .
303

, ,
.

,
. ,
.
o [1] ,
: , ,
, ,
. , , ,
..,
. -
, , , ,
. ,
.
, (free riders)
,
, ,
.
o [1] ,

. ,
, ,
, , , ,

, .
,
.
o ,
, ,
,
.
,
,

,
.
,
, ,
, .

[13,14], .
o
:
.
o
, . 92.
,
, , ,
, , , .
o
.
304

, ,
.
, ,
, .

92. .

o
,
.
, .
,
, . ,

.

.
.

.
, ,
, ,
, ..
.
, ,
. ,
, ,
. , ,
[11].
o . ,
, ,
. , ,

.
, .
o .
, ,
.
, , .
,
, , .
, ,
305

.
.
o .
.
, .
o . , ,
, ,
.
. ,
.
o .
. ,
, ,
,
.
o ,
. ,
.
, , .
o , , ,
.
o , ,
, .
, -
. 2-
,
.
o ,
, .

.
.
o . ,
, ,
,
,
.
.

. ,
-
.
,
.
,
, ,
, - , -
, - .
, ,
.
,
306

, - - .
, .
.
o . ,
.
,
,
, , .
. ,
.
o . ,
.
,
.
,
.
o . .
,

,
.
.
.
o . , ,
, , .
,
, ,
,
.
.
o .
.
, ,

, , ,
.
.
,
,
, .
, , ,
,
.
.

,
,
.
, , .

, .
, - .
307

, .
, ,
, ,
(
, ).
.
o ,
,
, .
o ,
, .
, ,
.
, .
o .
, ,
, ,
.
o ,
.
, , .


,
. ,
.
, , ,
, .
, .
, .
? -, , , , , -,
, , ,
, .
?
, ,
,
. ,
, .
, .
o
.
o ,
,
, .
o .
o
: , ;
.

308

o ,
,
.
o
. ,
.
, .
o
,
.
o
- .
o ,
,
.
-, , .
o , ()
, .
o
.
o
, , .
o
, , .
,
. .
.
.
, ,
.
4- 5-
, , , ,
.

.
.
.
. ,
,
.
. , ,
,
, ,
. ,
, .
. ,

, ,
309

,
.
,
, .
, , ,
.
, ,
,
.
,
,
( ) . ,
,
, ,
.



. ,
.
.
, , ,
, . ,
,
.

.
.

. ,
, , ,
, .

,
, ,
, .
-.

-
. ,
, , .
.

.

.

.
.
, , ,
.
310

,
,
.
, ,
.
o .
, ?
, ,
.

-? ,
,
, .

.
o . , ,
, ,
? , ,
.
o . ,
-?
, , ?
?
?
, ?
?
, ,
.

,
.
, ,
.
.
o .
,
.
,
(, ,
.).
o . ,
. ,
, .
o . ,
.
o . , .
.
,
- ,
. ,
. ,
311

, ,
.
, .
.
o , ,
,
.
o . , ,
.

( ),
( ).
.
.
o , .. ,
, , ,
.
o . , ,
: ,
,
, .
, ,
( )
( ,
).

, ,
. ,
, ,
.
, , .
o , .
o , ,
,
. ,
.
o , .
, ,
. , ,
.
,
, -
.
. 93.
o . ,
.

.
, , ,
312

, ,
.

93. .

o .
.

.
.

,
, .
o .
.
,
, , .
, ,
, .
,
, .
o . , , ,
.
,
, ,
.
o .

.
,
.
,
,
, .
.
, . ,
, ,
, , :
, , .

16
[1] . . . . .: , 2004.
313

[2] . , . . . .: ,
2001.
[3] . , . . . .: , 2004.
[4] ISO/IEC TR 14143-4:2002. Information Technology Software Measurement Functional
Size Measurement Part 4. Reference Model.
[5] ISO/IEC 20926:2003. Software Engineering IFPUG 4.1. Unadjusted Functional Size
Measurement Method Counting Practices Manual.
[6] . . . .: , 2002.
[7] . . . .: , 2002.
[8] COCOMO II Model Manual. 1999. http://sunset.usc.edu/research/COCOMOII/.
[9] COCOMO II User Manual. 1999. http://sunset.usc.edu/research/COCOMOII/.
[10] . . - . .:
-, 2001.
[11] . , . . : . .:
-, 2005.
[12] A. A. Maslow. Motivation and Personality. Harper and Row, NY, 1954.
[13] . Hersey, . . Blanchard. Management of Organizational Behavior: Utilizing Human
Resources. Prentice Hall, 1977.
[14] . , . , . .
. : , 2002.
[15] (PMBOK Guide). ANSI/PMI 99001-2004.
HTU

HTU

UTH

UTH

314