Skip to content

Commit bcb924a

Browse files
committed
placing solid_sample project
0 parents  commit bcb924a

File tree

11 files changed

+310
-0
lines changed

11 files changed

+310
-0
lines changed

DIP/correct/dip_correct.dart

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
abstract class Product {
2+
void seeReviews();
3+
void getSmaple();
4+
}
5+
6+
class Book implements Product {
7+
@override
8+
void getSmaple() {
9+
// TODO: implement getSmaple
10+
}
11+
12+
@override
13+
void seeReviews() {
14+
// TODO: implement seeReviews
15+
}
16+
}
17+
18+
class DVD implements Product {
19+
@override
20+
void getSmaple() {
21+
// TODO: implement getSmaple
22+
}
23+
24+
@override
25+
void seeReviews() {
26+
// TODO: implement seeReviews
27+
}
28+
}
29+
30+
class Shelf {
31+
Product? book;
32+
33+
void addBook(Product product) {}
34+
35+
void customizeShelf() {}
36+
}

DIP/wrong/dip.dart

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Book {
2+
void seeReviews() {}
3+
4+
void readSample() {}
5+
}
6+
7+
class DVD {
8+
void seeReviews() {}
9+
10+
void watchSample() {}
11+
}
12+
13+
class Shelf {
14+
Book? book;
15+
16+
void addBook(Book book) {}
17+
18+
void customizeShelf() {}
19+
}

ISP/correct/isp_correct.dart

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
abstract class Animal {
2+
void eat();
3+
void sleep();
4+
}
5+
6+
abstract class Flayable {
7+
void fly();
8+
}
9+
10+
class Bird implements Animal, Flayable {
11+
@override
12+
void eat() {}
13+
14+
@override
15+
void sleep() {}
16+
17+
@override
18+
void fly() {
19+
// TODO: implement fly
20+
}
21+
}
22+
23+
class Dog implements Animal {
24+
@override
25+
void eat() {}
26+
27+
@override
28+
void sleep() {}
29+
}

ISP/worng/isp.dart

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
abstract class Animal {
2+
void eat();
3+
void sleep();
4+
void fly();
5+
}
6+
7+
class Bird implements Animal {
8+
@override
9+
void eat() {}
10+
11+
@override
12+
void sleep() {}
13+
14+
@override
15+
void fly() {}
16+
}
17+
18+
class Dog implements Animal {
19+
@override
20+
void eat() {}
21+
22+
@override
23+
void sleep() {}
24+
25+
@override
26+
void fly() => throw Exception('Dogs cannot fly!');
27+
}

LSP/correct/lsp_correct.dart

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
abstract class MechanicalTestResult {
2+
void testResult();
3+
}
4+
5+
abstract class SoftwareTestResult {
6+
void codingTestResult();
7+
}
8+
9+
class MechanicalBranch implements MechanicalTestResult {
10+
@override
11+
void testResult() {
12+
// TODO: implement TestResult
13+
}
14+
}
15+
16+
class ComputerScienceBranch extends SoftwareTestResult {
17+
@override
18+
codingTestResult() {
19+
// some code
20+
}
21+
}

LSP/wrong/lsp.dart

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
abstract class Result {
2+
checkResult();
3+
4+
codingTestResult();
5+
}
6+
7+
class MechanicalBranch extends Result {
8+
@override
9+
checkResult() {
10+
// TODO: implement checkResult
11+
throw UnimplementedError();
12+
}
13+
14+
@override
15+
codingTestResult() {
16+
// TODO: implement codingTestResult
17+
throw UnimplementedError();
18+
}
19+
}
20+
21+
class ComputerScienceBranch extends Result {
22+
@override
23+
checkResult() {
24+
// some codet
25+
}
26+
27+
@override
28+
codingTestResult() {
29+
// some code
30+
}
31+
}

OCP/correct/ocp_correct.dart

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import 'dart:math';
2+
3+
abstract class Shape {
4+
double calacluteArea();
5+
}
6+
7+
class Rectangle extends Shape {
8+
final double width;
9+
final double height;
10+
Rectangle(this.width, this.height);
11+
12+
@override
13+
double calacluteArea() {
14+
return width * height;
15+
}
16+
}
17+
18+
class Circle extends Shape {
19+
final double radius;
20+
Circle(this.radius);
21+
22+
double get PI => 3.1415;
23+
24+
@override
25+
double calacluteArea() {
26+
return radius * radius * pi;
27+
}
28+
}
29+
30+
class Traingle extends Shape {
31+
final double radius;
32+
Traingle(this.radius);
33+
34+
double get PI => 3.1415;
35+
36+
@override
37+
double calacluteArea() {
38+
return radius * radius * pi;
39+
}
40+
}
41+
42+
class AreaCalculator {
43+
double calculate(Shape shape) {
44+
return shape.calacluteArea();
45+
}
46+
}

OCP/wrong/ocp.dart

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class Rectangle {
2+
final double width;
3+
final double height;
4+
const Rectangle(this.width, this.height);
5+
}
6+
7+
class Circle {
8+
final double radius;
9+
const Circle(this.radius);
10+
11+
double get PI => 3.1415;
12+
}
13+
14+
class AreaCalculator {
15+
double calculate(Object shape) {
16+
if (shape is Rectangle) {
17+
return shape.width * shape.height;
18+
} else {
19+
final c = shape as Circle;
20+
return c.radius * c.radius * c.PI;
21+
}
22+
}
23+
}

SRP/correct/shape_correct.dart

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
abstract class Shape {
2+
double Area();
3+
}
4+
5+
class Squre extends Shape {
6+
int side = 0;
7+
8+
@override
9+
double Area() {
10+
// TODO: implement Area
11+
throw side * side;
12+
}
13+
}
14+
15+
class Circle extends Shape {
16+
@override
17+
double Area() {
18+
// TODO: implement Area
19+
throw UnimplementedError();
20+
}
21+
}
22+
23+
class Rectangle extends Shape {
24+
@override
25+
double Area() {
26+
// TODO: implement Area
27+
throw UnimplementedError();
28+
}
29+
}
30+
31+
class ShpaesOnline {
32+
List<String> cache = [];
33+
34+
// GET requests
35+
String? wikiArticle(String figure) {
36+
/* ... */
37+
}
38+
39+
void _cacheElements(String text) {
40+
/* ... */
41+
}
42+
}
43+
44+
class ShapePrinter {
45+
void drawShape(Shape shape) {
46+
shape.Area();
47+
}
48+
}

SRP/wrong/shapes.dart

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import 'dart:web_gl';
2+
3+
class Shapes {
4+
// Calculations
5+
double? squareArea(double l) {
6+
/* ... */
7+
}
8+
9+
double? circleArea(double r) {
10+
/* ... */
11+
}
12+
13+
double? triangleArea(double b, double h) {
14+
/* ... */
15+
}
16+
17+
// Paint to the screen
18+
void paintSquare(Canvas c) {
19+
/* ... */
20+
}
21+
void paintCircle(Canvas c) {
22+
/* ... */
23+
}
24+
void paintTriangle(Canvas c) {
25+
/* ... */
26+
}
27+
}

main.dart

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
void main(List<String> args) {
2+
print('test');
3+
}

0 commit comments

Comments
 (0)