35
STAATLICH ANERKANNTE FACHHOCHSCHULE Author: Dip.-Inf. (FH) Johannes Hoppe Date: 27.10.2010 10.11.2010 STUDIEREN UND DURCHSTARTEN.

Ria 04 & 05 - First ASP.NET MVC project

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Ria 04 & 05 - First ASP.NET MVC project

STAATLICHANERKANNTEFACHHOCHSCHULE

Author: Dip.-Inf. (FH) Johannes HoppeDate: 27.10.2010

10.11.2010

STUDIERENUND DURCHSTARTEN.

Page 2: Ria 04 & 05 - First ASP.NET MVC project

STAATLICHANERKANNTEFACHHOCHSCHULE

RIA – Rich Internet Applications

Author: Dip.-Inf. (FH) Johannes HoppeDate: 27.10.2010

10.11.2010

Page 3: Ria 04 & 05 - First ASP.NET MVC project

First ASP.NET Project: WebNoteMvc

0109.04.2023

Folie 3

Page 4: Ria 04 & 05 - First ASP.NET MVC project

First ASP.NET Project: WebNoteMvc

09.04.2023

Folie 4

View(Presentation)

Controller Layer(Application flow controll)

Model(Business Layer)

Service Layer

Repository Layer

Data Access Layer

Page 5: Ria 04 & 05 - First ASP.NET MVC project

First ASP.NET Project: WebNoteMvc

Tiers for the Model

› Service Layer› Sub-Applications boundary “Access from outside”› CRUD, Validation, Transactions…› A good place to “talk” with other repositories

› Repository Layer› “Shields” application from real data access› A good place for caching

› Data Access Layer (here: Entity Framework)› Data mapper that moves data between objects and a database

(brutally simplified Martin Fowler: Patterns of Enterprise Application Architecture)

09.04.2023

Folie 5

Page 6: Ria 04 & 05 - First ASP.NET MVC project

First ASP.NET Project: WebNoteMvc

Implementation

› 1. We created a database and a table› 2. We created an EDMX file based on the database› 3. We used the plugin ”MCGe” to generate POCOs› 4. We created a repository layer with all CRUD operations› We did not created a service layer (for now)› 5. We changed the default controller to provide all CRUD operations› 6. We created views for every Controller operation

http://code.google.com/p/lecture-hoppe/downloads/detail?name=WebNoteMvc_v0.3.zip

09.04.2023

Folie 6

Page 7: Ria 04 & 05 - First ASP.NET MVC project

Repetition of creating “WebNoteMvc”

0209.04.2023

Folie 7

Page 8: Ria 04 & 05 - First ASP.NET MVC project

Repetition of creating “WebNoteMvc”

1. We created a database and a table

09.04.2023

Folie 8

Page 9: Ria 04 & 05 - First ASP.NET MVC project

Repetition of creating “WebNoteMvc”

2. We created an EDMX file based on the database

09.04.2023

Folie 9

Page 10: Ria 04 & 05 - First ASP.NET MVC project

Repetition of creating “WebNoteMvc”

3. We used the extension ”MCGe v0.3” to generate POCOs

09.04.2023

Folie 10

http://blog.johanneshoppe.de/2010/10/ado-net-mocking-context-generator-extended-walkthrough/

Page 11: Ria 04 & 05 - First ASP.NET MVC project

Repetition of creating “WebNoteMvc”

3. We used the extension ”MCGe v0.3” to generate POCOs

09.04.2023

Folie 11

Page 12: Ria 04 & 05 - First ASP.NET MVC project

Repetition of creating “WebNoteMvc”

4. We created a repository layer with all CRUD operations

09.04.2023

Folie 12

Page 13: Ria 04 & 05 - First ASP.NET MVC project

Repetition of creating “WebNoteMvc”

5. We changed the default controller to provide all CRUD operations

09.04.2023

Folie 13

Page 14: Ria 04 & 05 - First ASP.NET MVC project

Repetition of creating “WebNoteMvc”

6. We created views for every Controller operation

09.04.2023

Folie 14

Page 15: Ria 04 & 05 - First ASP.NET MVC project

Repetition of creating “WebNoteMvc”

09.04.2023

Folie 15

Page 16: Ria 04 & 05 - First ASP.NET MVC project

Repetition of creating “WebNoteMvc”

Questions?

?

09.04.2023

Folie 16

Page 17: Ria 04 & 05 - First ASP.NET MVC project

Unit Tests

0309.04.2023

Folie 17

Page 18: Ria 04 & 05 - First ASP.NET MVC project

Unit Tests

What?Why?

When?How?

09.04.2023

Folie 18

Page 19: Ria 04 & 05 - First ASP.NET MVC project

Unit Tests

What?

A piece of softwarethat (automatically)tests the smallest parts of an application.

09.04.2023

Folie 19

Page 20: Ria 04 & 05 - First ASP.NET MVC project

Unit Tests

What?

A unit test enables you to verifywhether a particular method

works as you intend it to work.

09.04.2023

Folie 20

Page 21: Ria 04 & 05 - First ASP.NET MVC project

Unit Tests

What?

A unit test is a straightforwardway to produce code

with a low error rate.

09.04.2023

Folie 21

Page 22: Ria 04 & 05 - First ASP.NET MVC project

Unit Tests

Why?

09.04.2023

Folie 22

Page 23: Ria 04 & 05 - First ASP.NET MVC project

Unit Tests

09.04.2023

Folie 23

Building tests for your code

avoids software bugs.

Page 24: Ria 04 & 05 - First ASP.NET MVC project

Unit Tests

09.04.2023

Folie 24

Building tests for your code

provides you with a safety net for change.

Page 25: Ria 04 & 05 - First ASP.NET MVC project

Unit Tests

09.04.2023

Folie 25

Building tests for your code

forces you to write loosely coupled code.

Page 26: Ria 04 & 05 - First ASP.NET MVC project

Unit Tests

09.04.2023

Folie 26

Building tests for your code

forces you to take a user perspective on the code.

Page 27: Ria 04 & 05 - First ASP.NET MVC project

Unit Tests

09.04.2023

Folie 27

Building tests for your code

provides a documentation for future coders.

Page 28: Ria 04 & 05 - First ASP.NET MVC project

Unit Tests

When?

09.04.2023

Folie 28

Page 29: Ria 04 & 05 - First ASP.NET MVC project

Unit Tests

When?

Always.or

Whenever it is plannedto reuse the software.

09.04.2023

Folie 29

Page 30: Ria 04 & 05 - First ASP.NET MVC project

Unit Tests

When?

Beforewriting the actual code.(Test-Driven Development)

09.04.2023

Folie 30

Page 31: Ria 04 & 05 - First ASP.NET MVC project

Unit Tests

When?

Test-Driven Development1. Write a unit test that fails.2. Write code that passes the unit tests.3. Refactor your code.

09.04.2023

Folie 31

Page 32: Ria 04 & 05 - First ASP.NET MVC project

Unit Tests

09.04.2023

Folie 32

How?

Page 33: Ria 04 & 05 - First ASP.NET MVC project

Unit Tests

Questions?

?

09.04.2023

Folie 33

Page 34: Ria 04 & 05 - First ASP.NET MVC project

Unit Tests

Your tasks:

› Try to write your first set of unit tests› Work together with you neighbor (2 persons, one team)› Use the Mock-Framework “Moq” from www.moq.me› Implement:

AddNoteTest, EditNoteTest, DeleteNoteTest DeleteNoteShouldThrowExceptionTest GetNoteShouldNotCallSaveChangesTest 6 Tests for the Controller

09.04.2023

Folie 34

Page 35: Ria 04 & 05 - First ASP.NET MVC project

THANK YOUFOR YOUR ATTENTION

09.04.2023

Folie 35