├── .gitignore ├── LICENSE ├── README.md ├── _config.yml ├── bootstrap ├── docs │ ├── box-model-01.png │ ├── box-model-02.gif │ ├── modulo01.md │ ├── modulo02.md │ ├── modulo03.md │ └── modulo04.md └── ejemplos │ ├── modulo01 │ ├── box-model.html │ └── starter-template.html │ ├── modulo02 │ ├── color-example.html │ ├── contenedores.html │ ├── grid-example-01.html │ ├── grid-example-02.html │ ├── grid-example-03.html │ ├── grid-example-04.html │ ├── grid-example-05.html │ ├── grid-example-06.html │ ├── grid-example-07.html │ ├── grid-example-08.html │ └── text-example.html │ ├── modulo03 │ ├── form-example-01.html │ ├── form-example-02.html │ ├── form-example-03.html │ ├── form-example-04.html │ ├── form-example-05.html │ ├── form-example-06.html │ └── form-example-07.html │ └── modulo04 │ ├── navbar-example-01.html │ ├── navbar-example-02.html │ ├── navbar-example-03.html │ ├── navbar-example-04.html │ ├── navbar-example-05.html │ ├── navbar-example-06.html │ ├── navbar-example-07.html │ └── template-simple │ ├── example-raven-01.html │ ├── example-raven-02.html │ ├── raven-back-left-100.jpg │ ├── raven-back-left.fw.png │ ├── raven-back-left.jpg │ ├── raven-back-right-100.jpg │ ├── raven-back-right.fw.png │ ├── raven-back-right.jpg │ ├── raven-back3-original.jpg │ └── raven.png ├── git ├── comandos-util.md └── modulo01 │ ├── git-layers.png │ └── modulo01.md ├── gradle ├── e1-hola-mundo │ └── build.gradle └── e2-lenguaje-dsl │ └── build.gradle ├── index.md ├── java8 ├── .classpath ├── .project ├── .settings │ └── org.eclipse.core.resources.prefs ├── docs │ ├── tema01.md │ ├── tema03.md │ └── tema04.md ├── resources │ └── data.txt └── src │ └── com │ └── jorgerdc │ └── java8 │ ├── comun │ └── Course.java │ ├── intro │ ├── CourseUtil.java │ ├── CourseUtilRefactor01.java │ ├── CourseUtilRefactor02.java │ └── CourseUtilRefactor03.java │ ├── modulo01 │ ├── CourseOrderingJava7.java │ ├── CourseOrderingJava8.java │ └── HiddenFilesExample.java │ ├── modulo02 │ ├── CoursePredicate.java │ ├── CoursePricePredicate.java │ ├── CourseUtil.java │ ├── CourseUtilAnonymousClass.java │ ├── CourseUtilComparator.java │ ├── CourseUtilLambda.java │ └── JavaCoursePredicate.java │ ├── modulo03 │ ├── ComparingMethodExample.java │ ├── LambdaExpressionsExample.java │ ├── MethodReferencesExample.java │ └── procesador │ │ ├── ReaderProcessor.java │ │ └── ReaderProcessorMain.java │ └── modulo04 │ ├── Student.java │ └── StudentMockDAO.java ├── junit5 ├── docs │ ├── modulo01.md │ ├── modulo02.md │ ├── modulo03.md │ └── modulo04.md └── junit-examples │ ├── .classpath │ ├── .project │ ├── .settings │ └── org.eclipse.buildship.core.prefs │ ├── build.gradle │ ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── src │ ├── main │ └── java │ │ └── com │ │ └── jorgerdc │ │ └── tutoriales │ │ └── junit5 │ │ ├── modulo01 │ │ └── MessageService.java │ │ └── modulo04 │ │ ├── DBUtils.java │ │ └── UserService.java │ └── test │ ├── java │ └── com │ │ └── jorgerdc │ │ └── tutoriales │ │ └── junit5 │ │ ├── modulo01 │ │ ├── MessageServiceMetaTest.java │ │ ├── MessageServiceTest.java │ │ └── TestSecurity.java │ │ ├── modulo02 │ │ ├── AssertAllExample.java │ │ ├── ExceptionTests.java │ │ ├── GroupedTests.java │ │ ├── NamedTests.java │ │ └── TestMethods.java │ │ ├── modulo03 │ │ ├── AssumptionsExample.java │ │ ├── ConditionalAnnotationsTests.java │ │ └── ProhibitedOs.java │ │ └── modulo04 │ │ ├── ClassInstanceLifeCycleTest.java │ │ ├── NestedTest.java │ │ ├── ProductionTests.java │ │ ├── RandomNamesParameterResolver.java │ │ ├── TestInfoParameterResolverExample.java │ │ ├── TestRandomNameExample.java │ │ ├── TestTagExamples.java │ │ └── UserServiceTest.java │ └── resources │ └── log4j.properties ├── lineamientos-desarrollo ├── README.md ├── eclipse │ ├── configuracion-eclipse-ws.md │ ├── eclipse-gral-ws.zip │ ├── img │ │ ├── e01.png │ │ ├── e02.png │ │ ├── e03.png │ │ ├── e04.png │ │ ├── e05.png │ │ ├── e06.png │ │ ├── e07.png │ │ ├── e08.png │ │ ├── e09.png │ │ ├── e10.png │ │ ├── e11.png │ │ ├── e12.png │ │ ├── e13.png │ │ ├── e14.png │ │ ├── e15.png │ │ ├── e16.png │ │ ├── e17.png │ │ ├── e18.png │ │ ├── e19.png │ │ ├── e20.png │ │ └── e21.png │ └── templates │ │ ├── template-debug.xml │ │ └── template-logdef.xml ├── github │ └── github-guidelines.md └── img │ ├── branch.png │ ├── branch2.png │ ├── fork.png │ ├── fork2.png │ ├── fork3.png │ ├── pull.png │ ├── pull2.png │ ├── pull3.png │ ├── pull4.png │ ├── pull5.png │ ├── pull6.png │ └── pull7.png ├── oci └── 01-fundamentos.md ├── programacion-reactiva ├── README.md ├── docs │ └── apuntes-01.md └── rxjava-ejemplos │ ├── .classpath │ ├── .project │ ├── .settings │ └── org.eclipse.buildship.core.prefs │ ├── build.gradle │ ├── settings.gradle │ └── src │ └── main │ └── java │ └── com │ └── jorgerdc │ └── rxjava │ ├── Libro.java │ ├── LibroClient.java │ ├── LibroDAO.java │ └── LibroService.java ├── reactjs ├── docs │ ├── modulo01.md │ ├── modulo02.md │ ├── modulo03.md │ ├── modulo04.md │ ├── modulo05.md │ ├── modulo06.md │ ├── modulo07.md │ ├── modulo08.md │ ├── modulo09 │ │ ├── app-default.png │ │ ├── estructura.png │ │ ├── modulo09.md │ │ ├── multiple-page.png │ │ └── single-page.png │ └── temario.md └── ejemplos │ ├── modulo01 │ ├── holaMundo.html │ ├── holaMundo.js │ └── holaMundoJSX.html │ ├── modulo02 │ └── componentes.html │ ├── modulo03 │ └── clock.html │ ├── modulo04 │ └── toggle.html │ ├── modulo05 │ ├── controlLogin.html │ └── mailBox.html │ ├── modulo06 │ ├── numberList.html │ └── ordenCompra.html │ ├── modulo07 │ ├── fileElement.html │ ├── multipleElements.html │ ├── nameForm.html │ ├── selectForm.html │ └── uncontrolledComponents.html │ ├── modulo08 │ ├── ajax-await-async.html │ └── ajax-window-fetch.html │ └── modulo09 │ ├── basic-react-app │ ├── .gitignore │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── public │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── logo192.png │ │ ├── logo512.png │ │ ├── manifest.json │ │ └── robots.txt │ └── src │ │ ├── App.css │ │ ├── App.js │ │ ├── App.test.js │ │ ├── index.css │ │ ├── index.js │ │ ├── logo.svg │ │ ├── serviceWorker.js │ │ └── setupTests.js │ └── caracteres-app │ ├── .gitignore │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── public │ ├── favicon.ico │ ├── index.html │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt │ └── src │ ├── App.css │ ├── App.js │ ├── App.test.js │ ├── Validador │ └── Validador.js │ ├── index.css │ ├── index.js │ ├── logo.svg │ ├── serviceWorker.js │ └── setupTests.js ├── scala ├── docs │ ├── tema01.md │ ├── tema02.md │ ├── tema03.md │ ├── tema04.md │ ├── tema05.md │ └── tema06.md ├── tema02 │ ├── for.scala │ ├── foreach.scala │ ├── saludo.scala │ └── while-imperativo.scala ├── tema03 │ ├── leeArchivoV1.scala │ ├── leeArchivoV2.scala │ └── sample.txt ├── tema04 │ ├── ChecksumAccumulator.scala │ ├── ChecksumApp.scala │ └── ChecksumTraitApp.scala └── tema06 │ ├── RationalAndThis.scala │ ├── RationalConstructors.scala │ ├── RationalInvalida.scala │ ├── RationalOperators.scala │ ├── RationalPrivateElements.scala │ └── RationalValida.scala ├── spring-boot ├── docs │ ├── t-01-introduccion.md │ ├── t-02-properties.md │ ├── t-03-logging.md │ └── t-04-profiles.md ├── hola-mundo-spring-boot │ ├── .classpath │ ├── .project │ ├── .settings │ │ ├── org.eclipse.buildship.core.prefs │ │ └── org.springframework.ide.eclipse.prefs │ ├── README.md │ ├── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── jorgerdc │ │ └── Application.java └── parent-spring-boot │ ├── .classpath │ ├── .project │ ├── .settings │ └── org.eclipse.buildship.core.prefs │ ├── build.gradle │ ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── properties-spring-boot │ ├── .classpath │ ├── .project │ ├── .settings │ │ ├── org.eclipse.buildship.core.prefs │ │ └── org.springframework.ide.eclipse.prefs │ ├── application.properties │ ├── build.gradle │ ├── config │ │ └── application.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── src │ │ ├── main │ │ └── java │ │ │ ├── application.properties │ │ │ ├── com │ │ │ └── jorgerdc │ │ │ │ └── tutoriales │ │ │ │ └── sboot │ │ │ │ ├── Application.java │ │ │ │ └── bean │ │ │ │ ├── Person.java │ │ │ │ └── Project.java │ │ │ └── config │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── jorgerdc │ │ └── toturiales │ │ └── sbot │ │ └── test │ │ └── junit │ │ └── PropertyTest.java │ └── settings.gradle └── typescript ├── docs ├── modulo01.md ├── modulo02.md └── temario.md └── ejemplos ├── modulo01 ├── .gitignore ├── 03-sintaxis-basico.ts ├── 04-tipos.ts ├── 06-variables.ts ├── 08-enumeraciones.ts ├── 09-tupla-vs-array.ts ├── 10-interfaces-tipos.ts ├── 11-union-interseccion.ts ├── 12-clases.ts ├── 13-1-namespaces.ts ├── 13-2-namespaces.ts ├── package.json ├── tsconfig.json ├── tslint.airbnb.json └── tslint.json └── modulo02 ├── .gitignore ├── README.md ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt ├── src ├── index.css ├── index.tsx ├── logo.svg ├── react-app-env.d.ts ├── serviceWorker.ts ├── setupTests.ts └── tic-tac-toe │ ├── board.tsx │ ├── game.css │ ├── game.tsx │ └── square.tsx └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_store 2 | build/ 3 | target/ 4 | bin/ 5 | .gradle/ 6 | .idea/ 7 | .dropbox 8 | Icon 9 | *~ 10 | Thumbs.db 11 | Thumbs.db:encryptable 12 | *.class 13 | *.log 14 | *.ctxt 15 | *.jar 16 | *.war 17 | *.nar 18 | *.ear 19 | *.zip 20 | *.tar.gz 21 | *.rar 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Jorge Rodríguez Campos 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tutoriales 2 | Este repositorio contiene material tipo tutorial de diversos temas: 3 | * Programación reactiva 4 | * Java 5 | * Scala 6 | * Spring framework 7 | * Spring boot 8 | * Git 9 | * JUnit 10 | * Log4J 11 | * Bootstrap 12 | * ReactJS 13 | * TypeScript 14 | ## Contribuciones 15 | * Todos los tutoriales están en constante actualización y desarrollo, algunos más completos que otros. 16 | * Todos los interesados en contribuir y aprender son bienvenidos a través de sus PRs 17 | 18 | 19 | Ver la carpeta correspondiente para detalles. El material está escrito empleando archivos md (MarkDown). 20 | 21 | 22 | 25 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /bootstrap/docs/box-model-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/bootstrap/docs/box-model-01.png -------------------------------------------------------------------------------- /bootstrap/docs/box-model-02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/bootstrap/docs/box-model-02.gif -------------------------------------------------------------------------------- /bootstrap/ejemplos/modulo01/box-model.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Content Box Vs Border Box 8 | 30 | 31 | 32 |

Content Box Vs Border Box

33 |
Content box 300 x 200
34 |
Border box 300 x 200
35 | 36 | -------------------------------------------------------------------------------- /bootstrap/ejemplos/modulo01/starter-template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 14 | Hola Mundo! 15 | 16 | 17 |

Hola Mundo!

18 | 19 | 20 | 21 | 25 | 29 | 34 | 35 | -------------------------------------------------------------------------------- /bootstrap/ejemplos/modulo02/contenedores.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 23 | 24 | Hello, world! 25 | 26 | 27 |
container-sm (small)
28 |
container-md (medium)
29 |
container-lg (large)
30 |
container-xl (extra large>
31 |
container
32 |
container-fluid (fluid)
33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /bootstrap/ejemplos/modulo02/grid-example-01.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 14 | grid-examples 15 | 16 | 17 |
18 |
Grid example 01
19 |
20 |
1
21 |
2
22 |
3
23 |
24 |
25 | 26 | 27 | 31 | 35 | 39 | 40 | -------------------------------------------------------------------------------- /bootstrap/ejemplos/modulo02/grid-example-02.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 14 | grid-examples 15 | 16 | 17 |
18 |
Grid example 02
19 |
20 |
1
21 |
2
22 |
23 |
Grid example 02
24 |
25 |
1
26 |
2
27 |
28 |
Grid example 03
29 |
30 |
1
31 |
2
32 |
3
33 |
4
34 |
35 |
36 | 37 | 38 | 42 | 46 | 50 | 51 | -------------------------------------------------------------------------------- /bootstrap/ejemplos/modulo02/grid-example-03.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 14 | grid-examples 15 | 16 | 17 |
18 |
Grid example 03
19 |
20 |
texto corto
21 |
texto que no es corto
22 |
texto que ocupa más espacio
23 |
24 |
25 | 26 | 27 | 31 | 35 | 39 | 40 | -------------------------------------------------------------------------------- /bootstrap/ejemplos/modulo02/grid-example-08.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | grid-examples 14 | 15 | 16 |
17 |
Grid example 08
18 |
Row 1
19 |
20 |
3,4
21 |
7,8
22 |
11,12
23 |
24 |
Row 2
25 |
26 |
1,2
27 |
11,12
28 |
29 |
Row 3
30 |
31 |
6,7-1,2
32 |
33 |
Row 4
34 |
35 |
1-6,1-2
36 |
37 |
38 | 39 | 40 | 41 | 45 | 49 | 54 | 55 | -------------------------------------------------------------------------------- /bootstrap/ejemplos/modulo03/form-example-02.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | form-example-02 14 | 15 | 16 |
17 |

Capturar usuario

18 |
19 |
Datos generales
20 |
21 |
22 | 23 | 24 |
25 |
26 | 27 | 28 |
29 | 30 |
31 |
32 | 33 | 34 | 38 | 42 | 46 | 47 | -------------------------------------------------------------------------------- /bootstrap/ejemplos/modulo03/form-example-03.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | form-example-01 14 | 15 | 16 | 17 |
18 |

Capturar usuario

19 |
Datos generales
20 |
21 |
22 |
23 |
24 | 25 |
26 |
27 | 28 |
29 |
30 |
31 |
32 | 33 | 34 | 38 | 42 | 46 | 47 | -------------------------------------------------------------------------------- /bootstrap/ejemplos/modulo04/navbar-example-01.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | navbar-example-01 14 | 15 | 16 | 17 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 43 | 47 | 51 | 52 | -------------------------------------------------------------------------------- /bootstrap/ejemplos/modulo04/navbar-example-02.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | navbar-example-02 14 | 15 | 16 | 17 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 43 | 47 | 51 | 52 | -------------------------------------------------------------------------------- /bootstrap/ejemplos/modulo04/navbar-example-03.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | navbar-example-03 14 | 15 | 16 | 17 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 44 | 48 | 52 | 53 | -------------------------------------------------------------------------------- /bootstrap/ejemplos/modulo04/navbar-example-04.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | navbar-example-04 14 | 15 | 16 | 17 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 49 | 53 | 57 | 58 | -------------------------------------------------------------------------------- /bootstrap/ejemplos/modulo04/template-simple/raven-back-left-100.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/bootstrap/ejemplos/modulo04/template-simple/raven-back-left-100.jpg -------------------------------------------------------------------------------- /bootstrap/ejemplos/modulo04/template-simple/raven-back-left.fw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/bootstrap/ejemplos/modulo04/template-simple/raven-back-left.fw.png -------------------------------------------------------------------------------- /bootstrap/ejemplos/modulo04/template-simple/raven-back-left.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/bootstrap/ejemplos/modulo04/template-simple/raven-back-left.jpg -------------------------------------------------------------------------------- /bootstrap/ejemplos/modulo04/template-simple/raven-back-right-100.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/bootstrap/ejemplos/modulo04/template-simple/raven-back-right-100.jpg -------------------------------------------------------------------------------- /bootstrap/ejemplos/modulo04/template-simple/raven-back-right.fw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/bootstrap/ejemplos/modulo04/template-simple/raven-back-right.fw.png -------------------------------------------------------------------------------- /bootstrap/ejemplos/modulo04/template-simple/raven-back-right.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/bootstrap/ejemplos/modulo04/template-simple/raven-back-right.jpg -------------------------------------------------------------------------------- /bootstrap/ejemplos/modulo04/template-simple/raven-back3-original.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/bootstrap/ejemplos/modulo04/template-simple/raven-back3-original.jpg -------------------------------------------------------------------------------- /bootstrap/ejemplos/modulo04/template-simple/raven.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/bootstrap/ejemplos/modulo04/template-simple/raven.png -------------------------------------------------------------------------------- /git/comandos-util.md: -------------------------------------------------------------------------------- 1 | # Git 2 | ## A1. Lista de comandos útiles. 3 | ##### Comando: 4 | * Hacer checkout de un branch remoto: 5 | * Se asume que el remote name es `origin` 6 | * Se emplea también para crear un nuevo branch que no existe en GitHub. 7 | ```bash 8 | git checkout -b origin/ 9 | ``` 10 | ##### Ejemplo: 11 | ```bash 12 | git checkout -b dev-jorge-update-sts-ws origin/dev-jorge-update-sts-ws 13 | ``` 14 | ##### Comando: 15 | * Eliminar un commit realizado localmente sin hacer `push` 16 | ```bash 17 | git reset --hard HEAD^ 18 | ``` 19 | * Este documento se irá actualizando conforme se use Git y se tenga más detalle técnico de su uso basado en la práctica. 20 | -------------------------------------------------------------------------------- /git/modulo01/git-layers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/git/modulo01/git-layers.png -------------------------------------------------------------------------------- /gradle/e1-hola-mundo/build.gradle: -------------------------------------------------------------------------------- 1 | task helloWorld{ 2 | doLast{ 3 | println 'Hola mundo!' 4 | } 5 | } 6 | 7 | task helloWorldShort << { 8 | println 'Hola mundo!' 9 | } -------------------------------------------------------------------------------- /gradle/e2-lenguaje-dsl/build.gradle: -------------------------------------------------------------------------------- 1 | task iniciaCanto <<{ 2 | canta() 3 | } 4 | 5 | def canta(){ 6 | ant.echo(message:'Vamos a cantar') //uso de ant 7 | } 8 | 9 | 3.times{ //creación de tareas dinámicas, su nombre se resuelve en runtime 10 | task "canto$it" <<{ 11 | println 'Gradle rocks!!!' 12 | } 13 | } 14 | 15 | canto0.dependsOn iniciaCanto 16 | canto2.dependsOn canto1,canto0 17 | task otraTarea(dependsOn: canto2){ 18 | println 'Otra tarea' 19 | } 20 | -------------------------------------------------------------------------------- /index.md: -------------------------------------------------------------------------------- 1 | ## Welcome to GitHub Pages 2 | 3 | You can use the [editor on GitHub](https://github.com/jorgerdc/tutoriales/edit/gh-pages/index.md) to maintain and preview the content for your website in Markdown files. 4 | 5 | Whenever you commit to this repository, GitHub Pages will run [Jekyll](https://jekyllrb.com/) to rebuild the pages in your site, from the content in your Markdown files. 6 | 7 | ### Markdown 8 | 9 | Markdown is a lightweight and easy-to-use syntax for styling your writing. It includes conventions for 10 | 11 | ```markdown 12 | Syntax highlighted code block 13 | 14 | # Header 1 15 | ## Header 2 16 | ### Header 3 17 | 18 | - Bulleted 19 | - List 20 | 21 | 1. Numbered 22 | 2. List 23 | 24 | **Bold** and _Italic_ and `Code` text 25 | 26 | [Link](url) and ![Image](src) 27 | ``` 28 | 29 | For more details see [GitHub Flavored Markdown](https://guides.github.com/features/mastering-markdown/). 30 | 31 | ### Jekyll Themes 32 | 33 | Your Pages site will use the layout and styles from the Jekyll theme you have selected in your [repository settings](https://github.com/jorgerdc/tutoriales/settings). The name of this theme is saved in the Jekyll `_config.yml` configuration file. 34 | 35 | ### Support or Contact 36 | 37 | Having trouble with Pages? Check out our [documentation](https://docs.github.com/categories/github-pages-basics/) or [contact support](https://github.com/contact) and we’ll help you sort it out. 38 | -------------------------------------------------------------------------------- /java8/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /java8/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | java8-01-basico 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /java8/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//docs/tema01.md=UTF-8 3 | -------------------------------------------------------------------------------- /java8/docs/tema04.md: -------------------------------------------------------------------------------- 1 | ## 4. Streams 2 | ### Definición 3 | * Un Stream permite manipular colecciones de datos en forma declarativa, similar a lenguajes como SQL: Se índica lo que se quiere realizar, pero se omite el *como* 4 | * Estas operaciones pueden ser procesadas de forma paralela de forma *transparente* (no requiere realizar programación adicional). 5 | * El uso de streams permite crear código 6 | * Declarativo 7 | * Flexible 8 | * Paralelizable. 9 | ### Método stream 10 | * Todas las colecciones a partir de Java 8 incorporan un nuevo método llamado ```stream``` que regresa una referencia a la interface ```java.util.stream.Stream``` 11 | * Este objeto representa el punto de partida para comenzar a trabajar con Streams. 12 | * Existen otros objetos a partir de los cuales se puede generar un Stream, no solo a través de colecciones. Por ejemplo, se puede obtener una secuencia de valores a partir de la definición de un rango ``` [Xmin,Xmax] 13 | ### Conceptos básicos 14 | #### Secuencia de elementos 15 | * Tanto una colección como un Stream está fuertemente relacionados con una secuencia o conjuntos de elementos pero con distintos enfoques: 16 | * En una colección el enfoque es su almacenamiento y acceso empleando diversas estructuras de datos: listas, pilas, colas, etc. 17 | * En un Stream, el enfoque son las operaciones y cálculos que se pueden aplicar a la secuencia de elementos: ordenamiento, filtrado, mapeo, etc. 18 | #### Origen o fuente 19 | * Streams consumen los elementos de una fuente, por ejemplo, colecciones, arreglos o recursos I/O. 20 | #### Operaciones 21 | * Operaciones a realizar sobre los elementos del stream: ```filter, map , reduce, find, mach, sort, ``` etc. Realizadas de forma secuencial o en paalelo. 22 | #### Pipelining 23 | * La mayoría de las operaciones regresan un Stream como resultado, lo que permite realizar encadenamiento de operaciones. Permite realizar optimizaciones como *laziness* y *short-circuiting* 24 | #### Iteraciones internas 25 | * Generalmente las iteraciones requeridas para trabajar con los elementos se hacen de forma implícita. 26 | -------------------------------------------------------------------------------- /java8/resources/data.txt: -------------------------------------------------------------------------------- 1 | Functional programming languages 2 | -Java (since Java8) 3 | -Scala 4 | -Groovy -------------------------------------------------------------------------------- /java8/src/com/jorgerdc/java8/comun/Course.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Course.java 3 | * Creation Date: 11/04/2018, 20:09:08 4 | * 5 | * Copyright (C) The Project *java8-01-basico* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | package com.jorgerdc.java8.comun; 16 | 17 | /** 18 | * POJO Course 19 | */ 20 | public class Course { 21 | 22 | private double price; 23 | 24 | private String name; 25 | 26 | /** 27 | * @param price 28 | * @param name 29 | */ 30 | public Course(String name, double price) { 31 | super(); 32 | this.price = price; 33 | this.name = name; 34 | } 35 | 36 | /** 37 | * @return the price 38 | */ 39 | public double getPrice() { 40 | return price; 41 | } 42 | 43 | /** 44 | * @param price the price to set 45 | */ 46 | public void setPrice(double price) { 47 | this.price = price; 48 | } 49 | 50 | /** 51 | * @return the name 52 | */ 53 | public String getName() { 54 | return name; 55 | } 56 | 57 | /** 58 | * @param name the name to set 59 | */ 60 | public void setName(String name) { 61 | this.name = name; 62 | } 63 | 64 | /* 65 | * See the original documentation of the method declaration 66 | * @see java.lang.Object#toString() 67 | */ 68 | @Override 69 | public String toString() { 70 | StringBuilder builder = new StringBuilder(); 71 | builder.append("Course [price="); 72 | builder.append(price); 73 | builder.append(", name="); 74 | builder.append(name); 75 | builder.append("]"); 76 | return builder.toString(); 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /java8/src/com/jorgerdc/java8/intro/CourseUtil.java: -------------------------------------------------------------------------------- 1 | /** 2 | * CourseUtil.java 3 | * Creation Date: 26/04/2018, 20:09:08 4 | * 5 | * Copyright (C) The Project *java8-01-basico* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | 16 | package com.jorgerdc.java8.intro; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import com.jorgerdc.java8.comun.Course; 22 | 23 | /** 24 | * Utility Course class without using Java8 main features. 25 | */ 26 | public class CourseUtil { 27 | 28 | /** 29 | * @param courses 30 | * @param courseName 31 | * @return 32 | */ 33 | public static List getCoursesByName(List courses, String courseName) { 34 | 35 | List javaCourses = new ArrayList<>(); 36 | for (Course course : courses) { 37 | if (course.getName().toLowerCase().contains(courseName)) { 38 | javaCourses.add(course); 39 | } 40 | } 41 | return javaCourses; 42 | } 43 | 44 | /** 45 | * @param courses 46 | * @param maxPrice 47 | * @return 48 | */ 49 | public static List getCoursesByMaxPrice(List courses, 50 | double maxPrice) { 51 | List javaCourses = new ArrayList<>(); 52 | for (Course course : courses) { 53 | if (course.getPrice() <= maxPrice) { 54 | javaCourses.add(course); 55 | } 56 | } 57 | return javaCourses; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /java8/src/com/jorgerdc/java8/intro/CourseUtilRefactor01.java: -------------------------------------------------------------------------------- 1 | /** 2 | * CourseUtilRefactor01.java 3 | * Creation Date: 11/04/2018, 20:09:08 4 | * 5 | * Copyright (C) The Project *java8-01-basico* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | package com.jorgerdc.java8.intro; 16 | 17 | import java.util.ArrayList; 18 | import java.util.Arrays; 19 | import java.util.List; 20 | import java.util.function.Predicate; 21 | 22 | import com.jorgerdc.java8.comun.Course; 23 | 24 | /** 25 | * Refactor of {@link CourseUtil} class using some new features of Java8 26 | */ 27 | public class CourseUtilRefactor01 { 28 | 29 | /** 30 | * @param c 31 | * @return 32 | */ 33 | public static boolean isJava(Course c) { 34 | return c.getName().toLowerCase().contains("java"); 35 | } 36 | 37 | /** 38 | * @param c 39 | * @param maxPrice 40 | * @return 41 | */ 42 | public static boolean isPriceLessThan(Course c, double maxPrice) { 43 | return c.getPrice() <= maxPrice; 44 | } 45 | 46 | /** 47 | * @param courses 48 | * @param p the predicate to apply ( Lambda expression) 49 | * @return 50 | */ 51 | public static List filterCourses(List courses, Predicate p) { 52 | 53 | List filteredCourses = new ArrayList<>(); 54 | for (Course c : courses) { 55 | if (p.test(c)) { 56 | filteredCourses.add(c); 57 | } 58 | } 59 | return filteredCourses; 60 | } 61 | 62 | /** 63 | * @param args 64 | */ 65 | public static void main(String[] args) { 66 | 67 | List courses, cursosJava; 68 | 69 | courses = Arrays.asList(new Course("Java", 8500), new Course("WebServices", 18500)); 70 | 71 | cursosJava = CourseUtilRefactor01.filterCourses(courses, CourseUtilRefactor01::isJava); 72 | 73 | System.out.println("Cursos de java"); 74 | System.out.println(cursosJava); 75 | 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /java8/src/com/jorgerdc/java8/intro/CourseUtilRefactor02.java: -------------------------------------------------------------------------------- 1 | /** 2 | * CourseUtilRefactor02.java 3 | * Creation Date: 11/04/2018, 20:09:08 4 | * 5 | * Copyright (C) The Project *java8-01-basico* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | package com.jorgerdc.java8.intro; 16 | 17 | import static java.util.Arrays.asList; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | import java.util.function.Predicate; 22 | 23 | import com.jorgerdc.java8.comun.Course; 24 | 25 | /** 26 | * Second Refactor of {@link CourseUtil} class. It shows more Java8 features. 27 | */ 28 | public class CourseUtilRefactor02 { 29 | 30 | /** 31 | * @param courses 32 | * @param p 33 | * @return 34 | */ 35 | public static List filterCourses(List courses, Predicate p) { 36 | 37 | List cursosFiltrados = new ArrayList<>(); 38 | for (Course c : courses) { 39 | if (p.test(c)) { 40 | cursosFiltrados.add(c); 41 | } 42 | } 43 | return cursosFiltrados; 44 | } 45 | 46 | /** 47 | * @param args 48 | */ 49 | public static void main(String[] args) { 50 | 51 | List courses, javaCourses, cheapCourses; 52 | 53 | courses = asList(new Course("Java", 8500), new Course("WebServices", 18500)); 54 | 55 | javaCourses = 56 | filterCourses(courses, c -> c.getName().toLowerCase().contains("java")); 57 | 58 | cheapCourses = filterCourses(courses, (Course c) -> c.getPrice() <= 10000); 59 | 60 | System.out.println("Java courses:"); 61 | System.out.println(javaCourses); 62 | 63 | System.out.println("Cheap courses:"); 64 | System.out.println(cheapCourses); 65 | 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /java8/src/com/jorgerdc/java8/intro/CourseUtilRefactor03.java: -------------------------------------------------------------------------------- 1 | /** 2 | * CourseUtilRefactor03.java 3 | * Creation Date: 11/04/2018, 20:09:08 4 | * 5 | * Copyright (C) The Project *java8-01-basico* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | package com.jorgerdc.java8.intro; 16 | 17 | import static java.util.Arrays.asList; 18 | 19 | import java.util.List; 20 | import java.util.stream.Collectors; 21 | 22 | import com.jorgerdc.java8.comun.Course; 23 | 24 | /** 25 | * Third refactor of {@link CourseUtil} class. It shows more Java8 features. 26 | */ 27 | public class CourseUtilRefactor03 { 28 | 29 | /** 30 | * @param args 31 | */ 32 | public static void main(String[] args) { 33 | List courses, javaCourses, cheapCourses; 34 | 35 | courses = asList(new Course("Java", 8500), new Course("WebServices", 18500)); 36 | 37 | javaCourses = 38 | courses.stream().filter(c -> c.getName().toLowerCase().contains("java")) 39 | .collect(Collectors.toList()); 40 | 41 | cheapCourses = courses.stream().filter((Course c) -> c.getPrice() <= 10000) 42 | .collect(Collectors.toList()); 43 | 44 | System.out.println("Java courses"); 45 | System.out.println(javaCourses); 46 | 47 | System.out.println("Cheap courses"); 48 | System.out.println(cheapCourses); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /java8/src/com/jorgerdc/java8/modulo01/CourseOrderingJava7.java: -------------------------------------------------------------------------------- 1 | /** 2 | * CourseOrderingJava7.java 3 | * Creation Date: 21/08/2018, 19:17:24 4 | * 5 | * Copyright (C) The Project *java8-01-basico* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | 16 | package com.jorgerdc.java8.modulo01; 17 | 18 | import java.util.Arrays; 19 | import java.util.Comparator; 20 | import java.util.List; 21 | 22 | import com.jorgerdc.java8.comun.Course; 23 | 24 | /** 25 | * This class shows how to Order a Course List using Java 7 26 | */ 27 | public class CourseOrderingJava7 { 28 | 29 | /** 30 | * Main method 31 | * @param args 32 | */ 33 | public static void main(String[] args) { 34 | List courses = Arrays.asList(new Course("Web Services", 7899.3), 35 | new Course("Java 8", 2100), new Course("C programming", 3400)); 36 | 37 | courses.sort(new Comparator() { 38 | 39 | @Override 40 | public int compare(Course o1, Course o2) { 41 | 42 | return o1.getName().compareTo(o2.getName()); 43 | } 44 | }); 45 | System.out.println("Ordered course list: " + courses); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /java8/src/com/jorgerdc/java8/modulo01/CourseOrderingJava8.java: -------------------------------------------------------------------------------- 1 | /** 2 | * CourseOrderingJava8.java 3 | * Creation Date: 21/08/2018, 19:29:58 4 | * 5 | * Copyright (C) The Project *java8-01-basico* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | 16 | package com.jorgerdc.java8.modulo01; 17 | 18 | import java.util.Arrays; 19 | import java.util.Comparator; 20 | import java.util.List; 21 | 22 | import com.jorgerdc.java8.comun.Course; 23 | 24 | /** 25 | * This class shows how to Order a Course List using Java 7 26 | */ 27 | public class CourseOrderingJava8 { 28 | 29 | /** 30 | * main method 31 | * @param args 32 | */ 33 | public static void main(String[] args) { 34 | List courses; 35 | 36 | courses = Arrays.asList(new Course("Web Services", 7899.3), 37 | new Course("Java 8", 2100), new Course("C programming", 3400)); 38 | 39 | courses.sort(Comparator.comparing(Course::getName)); 40 | 41 | System.out.println(courses); 42 | 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /java8/src/com/jorgerdc/java8/modulo01/HiddenFilesExample.java: -------------------------------------------------------------------------------- 1 | /** 2 | * CourseUtilRefactor03.java 3 | * Creation Date: 11/04/2018, 20:09:08 4 | * 5 | * Copyright (C) The Project *java8-01-basico* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | package com.jorgerdc.java8.modulo01; 16 | 17 | import java.io.File; 18 | import java.io.FileFilter; 19 | import java.util.Arrays; 20 | import java.util.List; 21 | 22 | /** 23 | * This example gets hidden files of a directory before and after Java8. 24 | */ 25 | public class HiddenFilesExample { 26 | 27 | /** 28 | * @param args 29 | */ 30 | public static void main(String[] args) { 31 | showHiddenFilesJava7(); 32 | showHiddendFilesJava8(); 33 | } 34 | 35 | /** 36 | * Shows hidden files using imperative programming style. 37 | */ 38 | private static void showHiddenFilesJava7() { 39 | File[] hiddenFiles; 40 | 41 | System.out.println("Showing hidden files before Java8. Verbose.."); 42 | hiddenFiles = 43 | new File(System.getProperty("java.io.tmpdir")).listFiles(new FileFilter() { 44 | @Override 45 | public boolean accept(File f) { 46 | return f.isHidden(); 47 | } 48 | }); 49 | for (File file : hiddenFiles) { 50 | System.out.println(file.getAbsolutePath()); 51 | } 52 | } 53 | 54 | /** 55 | * Shows hidden files using lambda expressions and method references. 56 | */ 57 | private static void showHiddendFilesJava8() { 58 | List files; 59 | String tmpDir; 60 | 61 | tmpDir = System.getProperty("java.io.tmpdir"); 62 | System.out.println("Showing hidden files with Java8 :"); 63 | 64 | // new in Java 8 65 | files = Arrays.asList(new File(tmpDir).listFiles(File::isHidden)); 66 | // new in Java 8 67 | files.forEach(System.out::println); 68 | 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /java8/src/com/jorgerdc/java8/modulo02/CoursePredicate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * CoursePredicate.java 3 | * Creation Date: 11/04/2018, 20:09:08 4 | * 5 | * Copyright (C) The Project *java8-01-basico* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | package com.jorgerdc.java8.modulo02; 16 | 17 | import java.util.function.Predicate; 18 | 19 | import com.jorgerdc.java8.comun.Course; 20 | 21 | /** 22 | * This simple interface represents a Predicate using {@link Course} objects. 23 | * Note that there is a functional interface {@link Predicate} that can be used 24 | * instead of this class. This topic will be reviewed later. 25 | */ 26 | public interface CoursePredicate { 27 | 28 | /** 29 | * Apply this predicate. 30 | * @param c 31 | * @return 32 | */ 33 | boolean test(Course c); 34 | } 35 | -------------------------------------------------------------------------------- /java8/src/com/jorgerdc/java8/modulo02/CoursePricePredicate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * CoursePricePredicate.java 3 | * Creation Date: 11/04/2018, 20:09:08 4 | * 5 | * Copyright (C) The Project *java8-01-basico* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | package com.jorgerdc.java8.modulo02; 16 | 17 | import com.jorgerdc.java8.comun.Course; 18 | 19 | /** 20 | * CoursePredicate implementation using its price as criteria 21 | */ 22 | public class CoursePricePredicate implements CoursePredicate { 23 | 24 | private double initialPrice; 25 | 26 | private double finalPrice; 27 | 28 | /** 29 | * @param costoInicial 30 | * @param finalPrice 31 | */ 32 | public CoursePricePredicate(double costoInicial, double finalPrice) { 33 | this.initialPrice = costoInicial; 34 | this.finalPrice = finalPrice; 35 | } 36 | 37 | /* 38 | * See the original documentation of the method declaration 39 | * @see 40 | * com.jorgerdc.java8.modulo02.CoursePredicate#test(com.jorgerdc.java8.intro.Course) 41 | */ 42 | @Override 43 | public boolean test(Course c) { 44 | return c.getPrice() >= initialPrice && c.getPrice() <= finalPrice; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /java8/src/com/jorgerdc/java8/modulo02/CourseUtil.java: -------------------------------------------------------------------------------- 1 | /** 2 | * CourseUtil.java 3 | * Creation Date: 11/04/2018, 20:09:08 4 | * 5 | * Copyright (C) The Project *java8-01-basico* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | package com.jorgerdc.java8.modulo02; 16 | 17 | import static java.util.Arrays.asList; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | import com.jorgerdc.java8.comun.Course; 23 | 24 | /** 25 | * Utility class used to test {@link CoursePredicate} implementations. 26 | */ 27 | public class CourseUtil { 28 | 29 | /** 30 | * Generic course filter 31 | * @param courses 32 | * @param p 33 | * @return 34 | */ 35 | public static List filterCourses(List courses, CoursePredicate p) { 36 | 37 | List filteredCourses; 38 | filteredCourses = new ArrayList<>(); 39 | for (Course course : courses) { 40 | if (p.test(course)) { 41 | filteredCourses.add(course); 42 | } 43 | } 44 | return filteredCourses; 45 | } 46 | 47 | /** 48 | * @param args 49 | */ 50 | public static void main(String[] args) { 51 | 52 | List courses; 53 | CoursePredicate predicado; 54 | 55 | courses = asList(new Course("Java", 8500), new Course("WebServices", 18500)); 56 | predicado = new JavaCoursePredicate(); 57 | 58 | System.out.println("Java Courses"); 59 | System.out.println(filterCourses(courses, predicado)); 60 | 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /java8/src/com/jorgerdc/java8/modulo02/CourseUtilAnonymousClass.java: -------------------------------------------------------------------------------- 1 | /** 2 | * CourseUtilAnonymousClass.java 3 | * Creation Date: 11/04/2018, 20:09:08 4 | * 5 | * Copyright (C) The Project *java8-01-basico* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | package com.jorgerdc.java8.modulo02; 16 | 17 | import static java.util.Arrays.asList; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | import com.jorgerdc.java8.comun.Course; 23 | 24 | /** 25 | * Course filter using an anonymous class 26 | */ 27 | public class CourseUtilAnonymousClass { 28 | 29 | /** 30 | * For every course on the list of courses, the Course predicate is applied using 31 | * the test method of the parameter p 32 | * @param courses 33 | * @param p 34 | * @return 35 | */ 36 | public static List filterCourses(List courses, CoursePredicate p) { 37 | 38 | List filteredCourses; 39 | filteredCourses = new ArrayList<>(); 40 | for (Course course : courses) { 41 | if (p.test(course)) { 42 | filteredCourses.add(course); 43 | } 44 | } 45 | return filteredCourses; 46 | } 47 | 48 | /** 49 | * @param args 50 | */ 51 | public static void main(String[] args) { 52 | 53 | List courses; 54 | 55 | courses = asList(new Course("Java", 8500), new Course("WebServices", 18500)); 56 | System.out.println("Java courses"); 57 | System.out.println(filterCourses(courses, new CoursePredicate() { 58 | @Override 59 | public boolean test(Course course) { 60 | return course.getName().toLowerCase().contains("java"); 61 | } 62 | })); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /java8/src/com/jorgerdc/java8/modulo02/CourseUtilComparator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * CourseUtilComparator.java 3 | * Creation Date: 11/04/2018, 20:09:08 4 | * 5 | * Copyright (C) The Project *java8-01-basico* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | package com.jorgerdc.java8.modulo02; 16 | 17 | import static java.util.Arrays.asList; 18 | 19 | import java.util.List; 20 | 21 | import com.jorgerdc.java8.comun.Course; 22 | 23 | /** 24 | * This class show how to create a comparator using a lambda expression. 25 | */ 26 | public class CourseUtilComparator { 27 | 28 | /** 29 | * @param args 30 | */ 31 | public static void main(String[] args) { 32 | 33 | List cursos; 34 | 35 | cursos = asList(new Course("Java", 8500), new Course("WebServices", 18500)); 36 | 37 | System.out.println("Sorting courses"); 38 | cursos.sort((Course c1, Course c2) -> c1.getName().compareTo(c2.getName())); 39 | System.out.println(cursos); 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /java8/src/com/jorgerdc/java8/modulo02/CourseUtilLambda.java: -------------------------------------------------------------------------------- 1 | package com.jorgerdc.java8.modulo02; 2 | 3 | import static java.util.Arrays.asList; 4 | 5 | /** 6 | * CourseUtilLambda.java 7 | * Creation Date: 11/04/2018, 20:09:08 8 | * 9 | * Copyright (C) The Project *java8-01-basico* Authors. 10 | * 11 | * This software was created for didactic and academic purposes. 12 | * It can be used and even modified by referring to the author 13 | * or project on GitHub. If the file is modified, add a note 14 | * after this paragraph saying that this file is a modified version. 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | */ 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | import com.jorgerdc.java8.comun.Course; 23 | 24 | /** 25 | * This class shows how to create a {@link CoursePredicate} implementation using 26 | * a lambda expression. 27 | */ 28 | public class CourseUtilLambda { 29 | 30 | /** 31 | * * For every course on the list of courses, the Course predicate is applied using 32 | * the test method of the parameter p 33 | * @param courses 34 | * @param p the predicate 35 | * @return 36 | */ 37 | public static List filterCourses(List courses, CoursePredicate p) { 38 | 39 | List filteredCourses; 40 | filteredCourses = new ArrayList<>(); 41 | for (Course course : courses) { 42 | if (p.test(course)) { 43 | filteredCourses.add(course); 44 | } 45 | } 46 | return filteredCourses; 47 | } 48 | 49 | /** 50 | * @param args 51 | */ 52 | public static void main(String[] args) { 53 | 54 | List courses; 55 | 56 | courses = asList(new Course("Java", 8500), new Course("WebServices", 18500)); 57 | 58 | System.out.println("Java courses"); 59 | System.out.println( 60 | filterCourses(courses, curso -> curso.getName().toLowerCase().contains("java"))); 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /java8/src/com/jorgerdc/java8/modulo02/JavaCoursePredicate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * JavaCoursePredicate.java 3 | * Creation Date: 11/04/2018, 20:09:08 4 | * 5 | * Copyright (C) The Project *java8-01-basico* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | package com.jorgerdc.java8.modulo02; 16 | 17 | import com.jorgerdc.java8.comun.Course; 18 | 19 | /** 20 | * CoursePredicate implementation. It filters Java course only. 21 | */ 22 | public class JavaCoursePredicate implements CoursePredicate { 23 | @Override 24 | public boolean test(Course curso) { 25 | return curso.getName().toLowerCase().contains("java"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /java8/src/com/jorgerdc/java8/modulo03/ComparingMethodExample.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ComparingMethodExample.java 3 | * Creation Date: 26/04/2018, 17:45:47 4 | * 5 | * Copyright (C) The Project *java8-01-basico* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | 16 | package com.jorgerdc.java8.modulo03; 17 | 18 | import static java.util.Comparator.comparing; 19 | 20 | import java.util.Arrays; 21 | import java.util.Comparator; 22 | import java.util.List; 23 | 24 | import com.jorgerdc.java8.comun.Course; 25 | 26 | /** 27 | * This example shows how to build a {@link Comparator} object using the 28 | * utility and static method {@link Comparator#comparing(java.util.function.Function)} 29 | */ 30 | 31 | public class ComparingMethodExample { 32 | 33 | /** 34 | * @param args 35 | */ 36 | public static void main(String[] args) { 37 | List courseList; 38 | 39 | courseList = 40 | Arrays.asList(new Course("Spring Framework", 230), new Course("Java 8", 130), 41 | new Course("Angular", 50), new Course("Zeppelin apache", 230)); 42 | 43 | System.out.println("sorting courses using it's name:"); 44 | courseList.sort(comparing(c -> c.getName())); 45 | System.out.println(courseList); 46 | 47 | System.out.println("sorting by name, then by price"); 48 | courseList 49 | .sort(comparing(Course::getName).thenComparing(Course::getPrice).reversed()); 50 | System.out.println(courseList); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /java8/src/com/jorgerdc/java8/modulo03/LambdaExpressionsExample.java: -------------------------------------------------------------------------------- 1 | /** 2 | * LambdaExpressionsExample.java 3 | * Creation Date: 19/04/2018, 14:34:15 4 | * 5 | * Copyright (C) The Project *java8-01-basico* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | package com.jorgerdc.java8.modulo03; 16 | 17 | import java.io.File; 18 | import java.util.Comparator; 19 | 20 | import com.jorgerdc.java8.comun.Course; 21 | 22 | /** 23 | * Examples of some lambda expressions 24 | */ 25 | public class LambdaExpressionsExample { 26 | 27 | /** 28 | * @param args 29 | */ 30 | @SuppressWarnings("unused") 31 | public static void main(String[] args) { 32 | Comparator oldComparator, lambdaComparator; 33 | 34 | // Before Java 8 (using anonymous class) 35 | oldComparator = new Comparator() { 36 | @Override 37 | public int compare(Course o1, Course o2) { 38 | return o1.getName().compareTo(o2.getName()); 39 | } 40 | }; 41 | // java 8 42 | lambdaComparator = (Course o1, Course o2) -> o1.getName().compareTo(o2.getName()); 43 | 44 | // Using lambda expression as a parameter of a method, using the concept of 45 | // functional interface. 46 | File myFiles; 47 | 48 | String[] filteredFiles; 49 | myFiles = new File("/tmp"); 50 | filteredFiles = 51 | myFiles.list((file, fileName) -> file.canWrite() && fileName.endsWith(".txt")); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /java8/src/com/jorgerdc/java8/modulo03/MethodReferencesExample.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ComparingMethodExample.java 3 | * Creation Date: 26/04/2018, 17:45:47 4 | * 5 | * Copyright (C) The Project *java8-01-basico* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | package com.jorgerdc.java8.modulo03; 16 | 17 | import java.io.File; 18 | import java.util.Arrays; 19 | import java.util.List; 20 | import java.util.function.Function; 21 | import java.util.function.Supplier; 22 | 23 | /** 24 | * 25 | */ 26 | public class MethodReferencesExample { 27 | 28 | /** 29 | * @param args 30 | */ 31 | public static void main(String[] args) { 32 | // example 1 33 | List list; 34 | list = Arrays.asList("M", "j", "x", "0", "a"); 35 | list.sort(String::compareToIgnoreCase); 36 | System.out.println(list); 37 | 38 | // example 2 39 | // without method references 40 | Supplier supplier = () -> "hello"; 41 | System.out.println("s1: " + supplier.get()); 42 | // with method references 43 | supplier = String::new; 44 | 45 | System.out.println("s2: " + supplier.get()); 46 | 47 | // example 3 48 | // without method references 49 | Function fx1 = (path) -> new File(path); 50 | File myFile = fx1.apply("/tmp/nonextisting.txt"); 51 | System.out.println(myFile.getAbsolutePath()); 52 | // with method references 53 | fx1 = File::new; 54 | myFile = fx1.apply("/tmp/nonextisting.txt"); 55 | System.out.println(myFile.getAbsolutePath()); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /java8/src/com/jorgerdc/java8/modulo03/procesador/ReaderProcessor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ReaderProcessor.java 3 | * Creation Date: 11/04/2018, 20:09:08 4 | * 5 | * Copyright (C) The Project *java8-01-basico* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | package com.jorgerdc.java8.modulo03.procesador; 16 | 17 | import java.io.BufferedReader; 18 | import java.io.IOException; 19 | 20 | /** 21 | * {@link BufferedReader} Processor modeled as a functional interface. 22 | */ 23 | @FunctionalInterface 24 | public interface ReaderProcessor { 25 | 26 | /** 27 | * This method is used to process a {@link BufferedReader} object . 28 | * The strategy is to separate the functional code from the code that is 29 | * needed to handle the {@link BufferedReader} creation and the code used to release 30 | * resources. The functional code will we passed as a parameter using lambda 31 | * expressions. 32 | * @param reader 33 | * @return A String object that represents the processing result. 34 | * @throws IOException if something goes wrong. This avoid handling exception directly 35 | * inside the lambda expression. 36 | */ 37 | String procesa(BufferedReader reader) throws IOException; 38 | } 39 | -------------------------------------------------------------------------------- /java8/src/com/jorgerdc/java8/modulo04/StudentMockDAO.java: -------------------------------------------------------------------------------- 1 | /** 2 | * StudentMockDAO.java 3 | * Creation Date: 26/04/2018, 20:17:15 4 | * 5 | * Copyright (C) The Project *java8-01-basico* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | 16 | package com.jorgerdc.java8.modulo04; 17 | 18 | import java.util.Arrays; 19 | import java.util.List; 20 | 21 | /** 22 | * Student Mock DAO used for testing 23 | */ 24 | public class StudentMockDAO { 25 | 26 | /** 27 | * @return Get all students. 28 | */ 29 | public static List getStudents() { 30 | return Arrays.asList(new Student(1, "John", 81, 1.7, 3), 31 | new Student(2, "Mike", 74.9, 1.77, 8), new Student(3, "Susan", 67, 1.6, 5), 32 | new Student(4, "Jio", 84, 1.5, 9), new Student(5, "Michel", 71, 1.8, 1), 33 | new Student(6, "Gio", 89, 1.9, 9)); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /junit5/junit-examples/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /junit5/junit-examples/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | junit-examples 4 | Project junit-examples created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.buildship.core.gradleprojectbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.buildship.core.gradleprojectnature 22 | 23 | 24 | -------------------------------------------------------------------------------- /junit5/junit-examples/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | connection.project.dir= 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /junit5/junit-examples/build.gradle: -------------------------------------------------------------------------------- 1 | group = 'com.jorgerdc.tutoriales.junit5' 2 | apply plugin: 'java' 3 | 4 | ext { 5 | slf4jVersion = '1.7.25' 6 | } 7 | 8 | test { 9 | useJUnitPlatform { 10 | excludeTags 'qa', 'prod' 11 | } 12 | testLogging { 13 | events "passed", "skipped", "failed" 14 | } 15 | } 16 | 17 | dependencies { 18 | 19 | compile "org.slf4j:slf4j-api:$slf4jVersion" 20 | runtime "org.slf4j:slf4j-log4j12:$slf4jVersion" 21 | 22 | //JUnit Jupiter API for writing tests and extensions. 23 | testCompile 'org.junit.jupiter:junit-jupiter-api:5.3.2' 24 | 25 | //junit-jupiter-engine is the implementation of junit-platform-engine 26 | //required only at runtime 27 | testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.3.2' 28 | 29 | //Annotations for configuring test suites on the JUnit Platform. 30 | //Supported by the JUnitPlatform runner and possibly by 31 | //third-party TestEngine implementations. 32 | //the following line was commented out to avoid adding JUnit4 dependencies 33 | // to the classpath. See Section 4.1.1 and 4.1.2 form more details. 34 | // testCompile 'org.junit.platform:junit-platform-suite-api:1.3.2' 35 | 36 | } 37 | 38 | repositories { 39 | jcenter() 40 | mavenCentral() 41 | } 42 | -------------------------------------------------------------------------------- /junit5/junit-examples/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/junit5/junit-examples/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /junit5/junit-examples/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /junit5/junit-examples/src/main/java/com/jorgerdc/tutoriales/junit5/modulo01/MessageService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * MessageService.java 3 | * Creation Date: 14 ene 2019, 17:54:31 4 | * 5 | * Copyright (C) The Project *junit-modulo01* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | 16 | package com.jorgerdc.tutoriales.junit5.modulo01; 17 | 18 | /** 19 | * This class implements a very simple message service to get custom messages. 20 | */ 21 | public class MessageService { 22 | 23 | /** 24 | * Gets "Hello World!" message. 25 | * @return 26 | */ 27 | public String helloWorld() { 28 | return "Hello World!"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /junit5/junit-examples/src/main/java/com/jorgerdc/tutoriales/junit5/modulo04/DBUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * DBUtils.java 3 | * Creation Date: 20 ene 2019, 18:22:55 4 | * 5 | * Copyright (C) The Project *junit-examples* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | 16 | package com.jorgerdc.tutoriales.junit5.modulo04; 17 | 18 | import java.util.HashMap; 19 | import java.util.Map; 20 | 21 | /** 22 | * This class represents a simple User Database 23 | */ 24 | 25 | public class DBUtils { 26 | 27 | static Map getUserList() { 28 | Map users; 29 | users = new HashMap<>(); 30 | users.put("u1", "pwd1"); 31 | users.put("u2", "pwd2"); 32 | users.put("u3", "pwd3"); 33 | users.put("u4", "pwd4"); 34 | users.put("u5", "pwd5"); 35 | return users; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /junit5/junit-examples/src/test/java/com/jorgerdc/tutoriales/junit5/modulo01/MessageServiceMetaTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * MessageServiceTest.java 3 | * Creation Date: 14 ene 2019, 17:57:44 4 | * 5 | * Copyright (C) The Project *junit-modulo01* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | 16 | package com.jorgerdc.tutoriales.junit5.modulo01; 17 | 18 | import org.junit.jupiter.api.Assertions; 19 | import org.junit.jupiter.api.Test; 20 | 21 | /** 22 | * MessageService Test case for JUnit 5 using a custom Annotation 23 | * @TestSecurity 24 | */ 25 | @TestSecurity 26 | public class MessageServiceMetaTest { 27 | 28 | /** 29 | * Test methods are annotate with @Test
30 | * Methods don't have to be public
31 | * Methods must not return a value. 32 | */ 33 | @Test 34 | void checkHelloWorldMessage() { 35 | MessageService service = new MessageService(); 36 | Assertions.assertEquals("Hello World!", service.helloWorld(), "Invalid message"); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /junit5/junit-examples/src/test/java/com/jorgerdc/tutoriales/junit5/modulo01/MessageServiceTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * MessageServiceTest.java 3 | * Creation Date: 14 ene 2019, 17:57:44 4 | * 5 | * Copyright (C) The Project *junit-modulo01* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | 16 | package com.jorgerdc.tutoriales.junit5.modulo01; 17 | 18 | import org.junit.jupiter.api.Assertions; 19 | import org.junit.jupiter.api.Test; 20 | 21 | /** 22 | * MessageService Test case for JUnit 5 23 | */ 24 | public class MessageServiceTest { 25 | 26 | /** 27 | * Test methods are annotate with @Test
28 | * Methods don't have to be public
29 | * Methods must not return a value. 30 | */ 31 | @Test 32 | void checkHelloWorldMessage() { 33 | MessageService service = new MessageService(); 34 | Assertions.assertEquals("Hello World!", service.helloWorld(), "Invalid message"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /junit5/junit-examples/src/test/java/com/jorgerdc/tutoriales/junit5/modulo01/TestSecurity.java: -------------------------------------------------------------------------------- 1 | /** 2 | * TestSecurity.java 3 | * Creation Date: 14 ene 2019, 20:09:02 4 | * 5 | * Copyright (C) The Project *junit-modulo01* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | 16 | package com.jorgerdc.tutoriales.junit5.modulo01; 17 | 18 | import static java.lang.annotation.ElementType.METHOD; 19 | import static java.lang.annotation.ElementType.TYPE; 20 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 | 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.Target; 24 | 25 | import org.junit.jupiter.api.Tag; 26 | 27 | /** 28 | * Annotation class used to show the Meta-Annotation concept. 29 | */ 30 | @Retention(RUNTIME) 31 | @Target({ TYPE, METHOD }) 32 | @Tag("security") 33 | public @interface TestSecurity { 34 | // no code 35 | } 36 | -------------------------------------------------------------------------------- /junit5/junit-examples/src/test/java/com/jorgerdc/tutoriales/junit5/modulo02/AssertAllExample.java: -------------------------------------------------------------------------------- 1 | /** 2 | * AssertAllExample.java 3 | * Creation Date: 16 ene 2019, 0:12:35 4 | * 5 | * Copyright (C) The Project *junit-modulo01* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | 16 | package com.jorgerdc.tutoriales.junit5.modulo02; 17 | 18 | import static org.junit.jupiter.api.Assertions.assertAll; 19 | import static org.junit.jupiter.api.Assertions.assertEquals; 20 | 21 | import org.junit.jupiter.api.Test; 22 | 23 | /** 24 | * This example shows how to test multiple assertions using assertAll. 25 | * All assertions are evaluated before reporting any failure or error. 26 | */ 27 | 28 | public class AssertAllExample { 29 | 30 | @Test 31 | void multipleAssertions() { 32 | 33 | int[] values = { 1, 2, 3, 4, 5 }; 34 | // change the second parameter to see the list of failed assertions. 35 | assertAll("Multiple validations", 36 | () -> assertEquals(values[0], 1, "Invalid result for values[0]"), 37 | () -> assertEquals(values[1], 2, "Invalid result for values[1]"), 38 | () -> assertEquals(values[2], 3, "Invalid result for values[2]"), 39 | () -> assertEquals(values[3], 4, "Invalid result for values[3]"), 40 | () -> assertEquals(values[4], 5, "Invalid result for values[4]")); 41 | 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /junit5/junit-examples/src/test/java/com/jorgerdc/tutoriales/junit5/modulo02/ExceptionTests.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ExceptionTests.java 3 | * Creation Date: 16 ene 2019, 16:12:18 4 | * 5 | * Copyright (C) The Project *junit-modulo01* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | 16 | package com.jorgerdc.tutoriales.junit5.modulo02; 17 | 18 | import static org.junit.jupiter.api.Assertions.assertThrows; 19 | 20 | import java.sql.SQLException; 21 | 22 | import org.junit.jupiter.api.Test; 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | /** 27 | * This class shows how to write tests that throws exceptions. 28 | */ 29 | 30 | public class ExceptionTests { 31 | 32 | private static final Logger log = LoggerFactory.getLogger(ExceptionTests.class); 33 | 34 | /** 35 | * The test expects an {@link SQLException}. If it is not thrown, the test fails. 36 | */ 37 | @Test 38 | void expectedException() { 39 | assertThrows(SQLException.class, () -> { 40 | log.debug("Throwing an expected exception"); 41 | throw new SQLException("DB error"); 42 | }); 43 | } 44 | 45 | /** 46 | * Similar to the previous tests, but now showing how to reuse the exception. 47 | */ 48 | @Test 49 | void reuseException() { 50 | Exception e; 51 | e = assertThrows(SQLException.class, () -> { 52 | log.debug("Throwing an expected exception"); 53 | throw new SQLException("DB error"); 54 | }); 55 | log.debug("the following expected exception was thrown, Type: {}, message: {} ", 56 | e.getClass(), e.getMessage()); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /junit5/junit-examples/src/test/java/com/jorgerdc/tutoriales/junit5/modulo02/NamedTests.java: -------------------------------------------------------------------------------- 1 | /** 2 | * NamedTests.java 3 | * Creation Date: 15 ene 2019, 22:50:23 4 | * 5 | * Copyright (C) The Project *junit-modulo01* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | 16 | package com.jorgerdc.tutoriales.junit5.modulo02; 17 | 18 | import static org.junit.jupiter.api.Assertions.assertEquals; 19 | 20 | import org.junit.jupiter.api.DisplayName; 21 | import org.junit.jupiter.api.Test; 22 | 23 | /** 24 | * This example show how to use @DisplayName in JUnit 5 25 | */ 26 | @DisplayName("Arithmetic tests") 27 | public class NamedTests { 28 | 29 | @Test 30 | @DisplayName(" 1 + 1 test") 31 | void sum() { 32 | assertEquals(2, 1 + 1, "Invalid result for 1 +1 "); 33 | // using lambda expressions. The construction of the message is delayed so it can 34 | // improve performance 35 | assertEquals(2, 1 + 1, () -> "Invalid result for " + (1 + 1) + "Expensive message"); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /junit5/junit-examples/src/test/java/com/jorgerdc/tutoriales/junit5/modulo03/ProhibitedOs.java: -------------------------------------------------------------------------------- 1 | /** 2 | * TestOnLinuxMac.java 3 | * Creation Date: 17 ene 2019, 23:37:53 4 | * 5 | * Copyright (C) The Project *junit-examples* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | 16 | package com.jorgerdc.tutoriales.junit5.modulo03; 17 | 18 | import static java.lang.annotation.ElementType.METHOD; 19 | import static java.lang.annotation.ElementType.TYPE; 20 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 | 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.Target; 24 | 25 | import org.junit.jupiter.api.condition.DisabledOnOs; 26 | import org.junit.jupiter.api.condition.OS; 27 | 28 | /** 29 | * Custom annotation used to represent both Linux and Mac Os 30 | */ 31 | @Retention(RUNTIME) 32 | @Target({ TYPE, METHOD }) 33 | @DisabledOnOs({ OS.WINDOWS, OS.AIX, OS.SOLARIS }) 34 | public @interface ProhibitedOs { 35 | // no code 36 | } 37 | -------------------------------------------------------------------------------- /junit5/junit-examples/src/test/java/com/jorgerdc/tutoriales/junit5/modulo04/NestedTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * NestedTest.java 3 | * Creation Date: 20 ene 2019, 15:56:18 4 | * 5 | * Copyright (C) The Project *junit-examples* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | 16 | package com.jorgerdc.tutoriales.junit5.modulo04; 17 | 18 | import org.junit.jupiter.api.AfterAll; 19 | import org.junit.jupiter.api.AfterEach; 20 | import org.junit.jupiter.api.BeforeAll; 21 | import org.junit.jupiter.api.BeforeEach; 22 | import org.junit.jupiter.api.Nested; 23 | import org.junit.jupiter.api.Test; 24 | import org.slf4j.Logger; 25 | import org.slf4j.LoggerFactory; 26 | 27 | /** 28 | * This test class does not have a particular meaning, it just shows how tne @Nested 29 | * tag works using inner classes. 30 | */ 31 | 32 | public class NestedTest { 33 | 34 | private static final Logger log = LoggerFactory.getLogger(NestedTest.class); 35 | 36 | @BeforeAll 37 | static void beforeAll() { 38 | log.debug("before all Test methods"); 39 | } 40 | 41 | @BeforeEach 42 | void beforeEach() { 43 | log.debug("before each test - Main class"); 44 | } 45 | 46 | @Nested 47 | class TestA { 48 | 49 | @BeforeEach 50 | void beforeEach() { 51 | log.debug("before each test - Test A class"); 52 | } 53 | 54 | @Nested 55 | class TestAA { 56 | 57 | @BeforeEach 58 | void beforeEach() { 59 | log.debug("before each test - Test AA class"); 60 | } 61 | 62 | @Test 63 | void testA() { 64 | log.debug("running testAA - Test AA class"); 65 | } 66 | 67 | @AfterEach 68 | void afterEach() { 69 | log.debug("after each test - Test AA class"); 70 | } 71 | } 72 | 73 | @AfterEach 74 | void afterEach() { 75 | log.debug("after each test - Test A class"); 76 | } 77 | 78 | } 79 | 80 | @AfterEach 81 | void afterEach() { 82 | log.debug("after each test - Main class"); 83 | } 84 | 85 | @AfterAll 86 | static void afterAll() { 87 | log.debug("after all Test methods"); 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /junit5/junit-examples/src/test/java/com/jorgerdc/tutoriales/junit5/modulo04/ProductionTests.java: -------------------------------------------------------------------------------- 1 | /** 2 | * ProductionTests.java 3 | * Creation Date: 19 ene 2019, 0:17:58 4 | * 5 | * Copyright (C) The Project *junit-examples* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | 16 | package com.jorgerdc.tutoriales.junit5.modulo04; 17 | 18 | import org.junit.platform.commons.annotation.Testable; 19 | 20 | /** 21 | * This class executes test methods of this package tagged as "prod". See 22 | * {@link TestTagExamples}. In this class only two method should be executed on 23 | * production. 24 | */ 25 | @Testable 26 | // @SelectPackages("com.jorgerdc.tutoriales.junit5.modulo04") 27 | // @SelectClasses(TestTagExamples.class) 28 | // @IncludeTags("prod") 29 | public class ProductionTests { 30 | // no code needed 31 | } 32 | -------------------------------------------------------------------------------- /junit5/junit-examples/src/test/java/com/jorgerdc/tutoriales/junit5/modulo04/TestRandomNameExample.java: -------------------------------------------------------------------------------- 1 | /** 2 | * TestRandomNameExample.java 3 | * Creation Date: 25 ene 2019, 23:52:00 4 | * 5 | * Copyright (C) The Project *junit-examples* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | 16 | package com.jorgerdc.tutoriales.junit5.modulo04; 17 | 18 | import static org.junit.jupiter.api.Assertions.assertTrue; 19 | 20 | import org.junit.jupiter.api.Test; 21 | import org.junit.jupiter.api.extension.ExtendWith; 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | 25 | import com.jorgerdc.tutoriales.junit5.modulo04.RandomNamesParameterResolver.RandomName; 26 | 27 | /** 28 | * This test class 29 | */ 30 | @ExtendWith(RandomNamesParameterResolver.class) 31 | public class TestRandomNameExample { 32 | 33 | private static final Logger log = LoggerFactory.getLogger(TestRandomNameExample.class); 34 | 35 | @Test 36 | void randomNumber(@RandomName String n1, @RandomName StringBuilder n2) { 37 | log.debug("Generated random names: {},{}", n1, n2); 38 | assertTrue(() -> checkRandomName(n1), "Invalid random name"); 39 | assertTrue(() -> checkRandomName(n2.toString()), "Invalid random name"); 40 | } 41 | 42 | @Test 43 | void moreRandomNames(@RandomName String n1) { 44 | log.debug("More generated random name: {}", n1); 45 | assertTrue(() -> checkRandomName(n1), "Invalid random name"); 46 | 47 | } 48 | 49 | boolean checkRandomName(String name) { 50 | return name.equals("Mike") || name.equals("Melli") || name.equals("Paty"); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /junit5/junit-examples/src/test/java/com/jorgerdc/tutoriales/junit5/modulo04/TestTagExamples.java: -------------------------------------------------------------------------------- 1 | /** 2 | * TestTagExamples.java 3 | * Creation Date: 19 ene 2019, 0:08:30 4 | * 5 | * Copyright (C) The Project *junit-examples* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | 16 | package com.jorgerdc.tutoriales.junit5.modulo04; 17 | 18 | import org.junit.jupiter.api.Tag; 19 | import org.junit.jupiter.api.Test; 20 | import org.slf4j.Logger; 21 | import org.slf4j.LoggerFactory; 22 | 23 | /** 24 | * This test class shows how to use the @Tag annotation. 25 | */ 26 | 27 | public class TestTagExamples { 28 | 29 | private static final Logger log = LoggerFactory.getLogger(TestTagExamples.class); 30 | 31 | @Tag("dev") 32 | @Test 33 | void testA() { 34 | log.debug("Running test on development environment"); 35 | } 36 | 37 | @Tag("qa") 38 | @Test 39 | void testB() { 40 | log.debug("Running test on quality server"); 41 | } 42 | 43 | @Tag("prod") 44 | @Test 45 | void testC() { 46 | log.debug("Running test on production"); 47 | } 48 | 49 | @Tag("dev") 50 | @Tag("qa") 51 | @Tag("prod") 52 | @Test 53 | void testD() { 54 | log.debug("Running test on all environments"); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /junit5/junit-examples/src/test/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootCategory=INFO, stdout 2 | 3 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 4 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{3}:%L - %m%n 6 | 7 | log4j.category.com.jorgerdc.tutoriales.junit5=DEBUG -------------------------------------------------------------------------------- /lineamientos-desarrollo/README.md: -------------------------------------------------------------------------------- 1 | ## Lineamientos de desarrollo 2 | ### 1.1 Introducción 3 | Esta carpeta contiene documentos que indican a nivel general la forma en la que se trabajará en los diferentes proyectos así como la instalación, configuración de las diferentes herramientas de desarrollo. 4 | Otro aspecto importante de estos documentos, es la adopción de convenciones y uso de buenas prácticas de tal forma que el código y el contenido de cada proyecto tenga la mejor calidad y pueda ser mantenido y entendido de forma ágil. 5 | Se recomienda revisar cada uno de los siguientes documentos en el orden que aparecen en las siguientes secciones. 6 | ### 1.2. Uso de Github. 7 | * En la subcarpeta `github` se encuentra un documento llamado `github-guidelines.md` En el se definen los lineamientos y buenas prácticas que deberán aplicarse para contribuir con los proyectos independientemente de su tipo. 8 | * En caso de requerir practicar con algún repo de prueba, se puede emplear con toda libertad el repo [git-testing](https://github.com/jorgerdc/git-testing) 9 | 10 | ### 1.3 Eclipse. 11 | * Para los proyectos que se deseen desarrollar con Eclipse como interfaz gráfica (IDE) se deberá realizar una configuración inicial con el objetivo principal de homologar estilos de programación, formato de código, etc. 12 | * La documentación se encuentra dentro de la carpeta `eclipse`. 13 | * Se hará uso de Spring Tool Suite (STS) como IDE principal de desarrollo. 14 | * STS es una variante de Eclipse que contiene funcionalidades adicionales para trabajar con proyectos que hacen uso del framework de Spring, aunque puede ser empleado para diversos tipos de proyectos. 15 | * Para iniciar con la configuración, seguir los siguientes pasos: 16 | 1. [Instalar STS](https://spring.io/tools) 17 | 2. Configurar STS con base al documento `configuracion-workspace.md`. 18 | 3. Una vez que STS haya sido configurada, ya se podrá realizar la importación de los proyectos y comenzar a trabajar. 19 | ##### Fin. Este documento se actualizará conforme se incorporen más herramientas de desarrollo. 20 | -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/eclipse-gral-ws.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/eclipse-gral-ws.zip -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/img/e01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/img/e01.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/img/e02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/img/e02.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/img/e03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/img/e03.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/img/e04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/img/e04.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/img/e05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/img/e05.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/img/e06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/img/e06.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/img/e07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/img/e07.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/img/e08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/img/e08.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/img/e09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/img/e09.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/img/e10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/img/e10.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/img/e11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/img/e11.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/img/e12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/img/e12.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/img/e13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/img/e13.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/img/e14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/img/e14.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/img/e15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/img/e15.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/img/e16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/img/e16.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/img/e17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/img/e17.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/img/e18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/img/e18.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/img/e19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/img/e19.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/img/e20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/img/e20.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/img/e21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/eclipse/img/e21.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/templates/template-debug.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lineamientos-desarrollo/eclipse/templates/template-logdef.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lineamientos-desarrollo/img/branch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/img/branch.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/img/branch2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/img/branch2.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/img/fork.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/img/fork.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/img/fork2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/img/fork2.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/img/fork3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/img/fork3.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/img/pull.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/img/pull.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/img/pull2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/img/pull2.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/img/pull3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/img/pull3.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/img/pull4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/img/pull4.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/img/pull5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/img/pull5.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/img/pull6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/img/pull6.png -------------------------------------------------------------------------------- /lineamientos-desarrollo/img/pull7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/lineamientos-desarrollo/img/pull7.png -------------------------------------------------------------------------------- /programacion-reactiva/README.md: -------------------------------------------------------------------------------- 1 | # Tutorial - Programación Reactiva 2 | La documentación de este tutorial se encuentra en la carpeta docs 3 | -------------------------------------------------------------------------------- /programacion-reactiva/rxjava-ejemplos/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /programacion-reactiva/rxjava-ejemplos/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | rxjava-ejemplos 4 | Project rxjava-ejemplos created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.buildship.core.gradleprojectbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.buildship.core.gradleprojectnature 22 | 23 | 24 | -------------------------------------------------------------------------------- /programacion-reactiva/rxjava-ejemplos/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | connection.project.dir= 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /programacion-reactiva/rxjava-ejemplos/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | repositories { 4 | mavenCentral() 5 | jcenter() 6 | } 7 | sourceCompatibility = 1.8 8 | targetCompatibility = 1.8 9 | 10 | tasks.withType(JavaCompile) { 11 | options.encoding = 'ISO-8859-1' 12 | } 13 | 14 | dependencies { 15 | testCompile 'junit:junit:4.12' 16 | compile 'org.slf4j:slf4j-api:1.7.25' 17 | runtime 'org.slf4j:slf4j-log4j12:1.7.25' 18 | compile 'io.reactivex.rxjava2:rxjava:2.1.9' 19 | } 20 | -------------------------------------------------------------------------------- /programacion-reactiva/rxjava-ejemplos/settings.gradle: -------------------------------------------------------------------------------- 1 | 2 | rootProject.name = 'rxjava-ejemplos' 3 | -------------------------------------------------------------------------------- /programacion-reactiva/rxjava-ejemplos/src/main/java/com/jorgerdc/rxjava/Libro.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Este software puede ser modificado o utilizado haciendo referencia al autor. 15/02/2018 3 | */ 4 | package com.jorgerdc.rxjava; 5 | 6 | /** 7 | * TODO: File description 8 | * 9 | * @author Jorge A. Rodriguez Campos (jorgerdc@gmail.com) 10 | */ 11 | public class Libro { 12 | 13 | private String nombre; 14 | 15 | private String clave; 16 | 17 | /** 18 | * @param nombre 19 | * @param clave 20 | */ 21 | public Libro(String nombre, String clave) { 22 | super(); 23 | this.nombre = nombre; 24 | this.clave = clave; 25 | } 26 | 27 | /** 28 | * @return the nombre 29 | */ 30 | public String getNombre() { 31 | return nombre; 32 | } 33 | 34 | /** 35 | * @param nombre 36 | * the nombre to set 37 | */ 38 | public void setNombre(String nombre) { 39 | this.nombre = nombre; 40 | } 41 | 42 | /** 43 | * @return the clave 44 | */ 45 | public String getClave() { 46 | return clave; 47 | } 48 | 49 | /** 50 | * @param clave 51 | * the clave to set 52 | */ 53 | public void setClave(String clave) { 54 | this.clave = clave; 55 | } 56 | 57 | /* 58 | * (non-Javadoc) 59 | * @see java.lang.Object#toString() 60 | */ 61 | @Override 62 | public String toString() { 63 | StringBuilder builder = new StringBuilder(); 64 | builder.append("Libro [nombre="); 65 | builder.append(nombre); 66 | builder.append(", clave="); 67 | builder.append(clave); 68 | builder.append("]"); 69 | return builder.toString(); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /programacion-reactiva/rxjava-ejemplos/src/main/java/com/jorgerdc/rxjava/LibroClient.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/programacion-reactiva/rxjava-ejemplos/src/main/java/com/jorgerdc/rxjava/LibroClient.java -------------------------------------------------------------------------------- /programacion-reactiva/rxjava-ejemplos/src/main/java/com/jorgerdc/rxjava/LibroDAO.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/programacion-reactiva/rxjava-ejemplos/src/main/java/com/jorgerdc/rxjava/LibroDAO.java -------------------------------------------------------------------------------- /programacion-reactiva/rxjava-ejemplos/src/main/java/com/jorgerdc/rxjava/LibroService.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/programacion-reactiva/rxjava-ejemplos/src/main/java/com/jorgerdc/rxjava/LibroService.java -------------------------------------------------------------------------------- /reactjs/docs/modulo09/app-default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/reactjs/docs/modulo09/app-default.png -------------------------------------------------------------------------------- /reactjs/docs/modulo09/estructura.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/reactjs/docs/modulo09/estructura.png -------------------------------------------------------------------------------- /reactjs/docs/modulo09/multiple-page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/reactjs/docs/modulo09/multiple-page.png -------------------------------------------------------------------------------- /reactjs/docs/modulo09/single-page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/reactjs/docs/modulo09/single-page.png -------------------------------------------------------------------------------- /reactjs/docs/temario.md: -------------------------------------------------------------------------------- 1 |  2 | 3 | # ReactJS (v16.13.1) 4 | ## 1. Hola mundo (*) 5 | ### 1.1 Que es react ? 6 | ### 1.2 JSX: JavaScript extension 7 | ### 1.3 Hola Mundo con React 8 | #### 1.3.2 Hola Mundo con React y JSX 9 | #### 1.3.3 Agregando soporte de JSX a un proyecto. 10 | ### 1.4 ToolChains 11 | ## 2. Render de Elementos y Componentes y sus atributos (*) 12 | ### 2.1 Elementos en ReactJS 13 | ### 2.1.1 Render de elementos 14 | ### 2.1.2 Actualización dinámica 15 | ### 2.2 Componentes en ReactJS 16 | ### 2.2.1 Componentes de componentes 17 | 18 | ## 3. Estado y ciclo de vida de un componente. (*) 19 | ### 3.1 Estado de un componente 20 | #### 3.1.1 Conversión de un function component a una Clase. 21 | #### 3.1.2 Agregando local state a la clase. 22 | #### 3.1.3 Agregando métodos para controlar el ciclo de vida de un componente. 23 | #### 3.1.4 Algunas reglas para administrar el estado de un componente. 24 | 25 | ## 4. Manejo de eventos 26 | ### 4.1 Pasar argumentos a los controladores de eventos 27 | ## 5. Renderizado Condicional 28 | ### 5.1 Variables de elementos 29 | ### 5.2 En línea "if" con el operador lógico && 30 | ### 5.3 En línea "if-else" con el operador condicional. 31 | ### 5.4 Prevención de componentes en la renderización. 32 | ## 6. Listas y claves 33 | ### 6.1 Renderizando multiples componentes 34 | ### 6.2 Lista básica de componentes 35 | ### 6.3 Llaves 36 | ### 6.4 Obtener componentes con llaves 37 | ### 6.5 Las llaves solo deben ser únicas entre "Siblings" 38 | ### 6.6 Agregando map() en JSX 39 | ## 7. Formularios 40 | ### 7.1 Control de componentes 41 | ### 7.2 Etiqueta textarea 42 | ### 7.3 Etiqueta select 43 | ### 7.4 Etiqueta file input 44 | ### 7.5 Manejo de múltiples entradas 45 | ### 7.6 Control de entradas nulas 46 | ### 7.7 Alternativas para controlar controlar componentes 47 | ### 7.8 Soluciones completas 48 | ## 8. Levantando estados 49 | ### 8.1 Agregando una segunda entrada 50 | ### 8.2 Escribir funciones de conversión 51 | ### 8.3 Levantando estados 52 | ## 9. Composición vs Herencia 53 | ### 9.1 Contención 54 | ### 9.2 Especialización 55 | ### 9.3 Entonces ¿Qué paso con la herencia ? 56 | ## 10. Pensando en React 57 | ### 10.1 Desarrollando un Mock en varios pasos 58 | 59 | Note: (*) Temas desarrollados 60 | 61 | ***Liga a documentación oficial*** 62 | [https://reactjs.org/docs/getting-started.html](https://reactjs.org/docs/getting-started.html) 63 | 64 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo01/holaMundo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hola Mundo con React 6 | 7 | 8 | 9 |

Iniciando con React

10 | 11 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo01/holaMundo.js: -------------------------------------------------------------------------------- 1 | const element = React.createElement( 2 | 'h1', 3 | {className: 'saludo'}, 4 | 'Hola Mundo!' 5 | ); 6 | 7 | ReactDOM.render( 8 | element, 9 | document.getElementById('root') 10 | ); 11 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo01/holaMundoJSX.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hola Mundo con React y JSX 6 | 7 | 8 |

Iniciando con React

9 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 33 | 34 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo02/componentes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Componentes en React con JSX 6 | 7 | 8 |

Componentes en React con JSX

9 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 44 | 45 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo04/toggle.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Toggle con ReactJS 6 | 7 | 8 |

Toggle con ReactJS - JSX

9 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 62 | 63 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo05/mailBox.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Correo electrónico con ReactJS 6 | 7 | 8 |

Correo electrónico con ReactJS - JSX

9 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 45 | 46 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo06/numberList.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Lista de compoentes ReactJS 6 | 7 | 8 |

Lista de compoentes - JSX

9 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 38 | 39 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo06/ordenCompra.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Orden de compra ReactJS 6 | 7 | 8 |

Lista de productos

9 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 40 | 41 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo07/fileElement.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Formulario básico ReactJS 6 | 7 | 8 |

Elemento File - Uso de Refs.

9 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 44 | 45 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo07/nameForm.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Formulario básico ReactJS 6 | 7 | 8 |

Capturar nombre

9 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 55 | 56 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo07/selectForm.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Formulario básico ReactJS 6 | 7 | 8 |

Capturar Nivel de entrenamiento

9 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 52 | 53 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo07/uncontrolledComponents.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Formulario básico ReactJS 6 | 7 | 8 |

Manejo de Uncontrolled elements - Uso de Refs.

9 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 61 | 62 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo08/ajax-await-async.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AJAX básico con ReactJS 6 | 7 | 8 |

Peticiones AJAX - ReactJS

9 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 73 | 74 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/basic-react-app/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/basic-react-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "basic-react-app", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^4.2.4", 7 | "@testing-library/react": "^9.5.0", 8 | "@testing-library/user-event": "^7.2.1", 9 | "react": "^16.13.1", 10 | "react-dom": "^16.13.1", 11 | "react-scripts": "3.4.1" 12 | }, 13 | "scripts": { 14 | "start": "react-scripts start", 15 | "build": "react-scripts build", 16 | "test": "react-scripts test", 17 | "eject": "react-scripts eject" 18 | }, 19 | "eslintConfig": { 20 | "extends": "react-app" 21 | }, 22 | "browserslist": { 23 | "production": [ 24 | ">0.2%", 25 | "not dead", 26 | "not op_mini all" 27 | ], 28 | "development": [ 29 | "last 1 chrome version", 30 | "last 1 firefox version", 31 | "last 1 safari version" 32 | ] 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/basic-react-app/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/reactjs/ejemplos/modulo09/basic-react-app/public/favicon.ico -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/basic-react-app/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/basic-react-app/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/reactjs/ejemplos/modulo09/basic-react-app/public/logo192.png -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/basic-react-app/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/reactjs/ejemplos/modulo09/basic-react-app/public/logo512.png -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/basic-react-app/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/basic-react-app/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/basic-react-app/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/basic-react-app/src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import logo from './logo.svg'; 3 | import './App.css'; 4 | 5 | function App() { 6 | return ( 7 |
8 |
9 | logo 10 |

11 | Edit src/App.js and save to reload. 12 |

13 | 19 | Learn React 20 | 21 |
22 |
23 | ); 24 | } 25 | 26 | export default App; 27 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/basic-react-app/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | const { getByText } = render(); 7 | const linkElement = getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/basic-react-app/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/basic-react-app/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ); 13 | 14 | // If you want your app to work offline and load faster, you can change 15 | // unregister() to register() below. Note this comes with some pitfalls. 16 | // Learn more about service workers: https://bit.ly/CRA-PWA 17 | serviceWorker.unregister(); 18 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/basic-react-app/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/caracteres-app/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/caracteres-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caracteres-app", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^4.2.4", 7 | "@testing-library/react": "^9.5.0", 8 | "@testing-library/user-event": "^7.2.1", 9 | "react": "^16.13.1", 10 | "react-dom": "^16.13.1", 11 | "react-scripts": "3.4.3" 12 | }, 13 | "scripts": { 14 | "start": "react-scripts start", 15 | "build": "react-scripts build", 16 | "test": "react-scripts test", 17 | "eject": "react-scripts eject" 18 | }, 19 | "eslintConfig": { 20 | "extends": "react-app" 21 | }, 22 | "browserslist": { 23 | "production": [ 24 | ">0.2%", 25 | "not dead", 26 | "not op_mini all" 27 | ], 28 | "development": [ 29 | "last 1 chrome version", 30 | "last 1 firefox version", 31 | "last 1 safari version" 32 | ] 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/caracteres-app/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/reactjs/ejemplos/modulo09/caracteres-app/public/favicon.ico -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/caracteres-app/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/caracteres-app/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/reactjs/ejemplos/modulo09/caracteres-app/public/logo192.png -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/caracteres-app/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/reactjs/ejemplos/modulo09/caracteres-app/public/logo512.png -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/caracteres-app/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/caracteres-app/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/caracteres-app/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | margin: 20px; 3 | } 4 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/caracteres-app/src/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import './App.css'; 3 | import Validador from './Validador/Validador'; 4 | 5 | 6 | class App extends Component { 7 | /** 8 | * Estado del componente 9 | */ 10 | state ={ 11 | texto : '' 12 | } 13 | 14 | /** 15 | * Método empleado para manejar el evento onChange. Notar que se 16 | * hace uso de una variable para hacer referencia a dicho método 17 | */ 18 | textoOnChangeHandler = (event) => { 19 | this.setState({texto: event.target.value}); 20 | } 21 | 22 | render() { 23 | return ( 24 |
25 |

App Caracteres

26 |
27 |

Capturar algún texto:

28 |
29 | 33 |
34 |

{this.state.texto}

35 | 36 |
37 | ); 38 | } 39 | } 40 | 41 | export default App; 42 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/caracteres-app/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | const { getByText } = render(); 7 | const linkElement = getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/caracteres-app/src/Validador/Validador.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | const Validador = (props) => { 4 | let mensaje; 5 | if (props.longitud < 5){ 6 | mensaje =

El valor de longitud {props.longitud} es muy corto

7 | } else { 8 | mensaje =

El valor de longitud {props.longitud} es correcto

9 | } 10 | return ( 11 |
12 | {mensaje} 13 |
14 | ) 15 | } 16 | export default Validador -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/caracteres-app/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/caracteres-app/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ); 13 | 14 | // If you want your app to work offline and load faster, you can change 15 | // unregister() to register() below. Note this comes with some pitfalls. 16 | // Learn more about service workers: https://bit.ly/CRA-PWA 17 | serviceWorker.unregister(); 18 | -------------------------------------------------------------------------------- /reactjs/ejemplos/modulo09/caracteres-app/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /scala/tema02/for.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * script: for.scala 3 | * Imprimineodo argumentos estilo funcional con for 4 | */ 5 | 6 | for( arg <- args ) 7 | print(" "+arg) 8 | println -------------------------------------------------------------------------------- /scala/tema02/foreach.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * script: foreach.scala 3 | * Imprimineodo argumentos estilo funcional 4 | */ 5 | 6 | println("foreach") 7 | args.foreach(arg => print(" " + arg)) 8 | println() 9 | 10 | println("foreach con tipos de datos") 11 | args.foreach((arg: String) => print(" " + arg)) 12 | println() 13 | 14 | println("partially applied function") 15 | args.foreach(println) 16 | println() -------------------------------------------------------------------------------- /scala/tema02/saludo.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * script: saludo.scala 3 | * saludando con argumentos 4 | */ 5 | println("Hola mundo "+ args(0) +" desde script ") 6 | 7 | println("Hola mundo "+ args(0) +" desde script ") -------------------------------------------------------------------------------- /scala/tema02/while-imperativo.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * script: while-imperativo.scala 3 | * Imprimineodo argumentos con while 4 | */ 5 | var i = 0 6 | while(i < args.length){ 7 | if(i!=0){ 8 | print(" ") 9 | } 10 | print(args(i)) 11 | i = i +1 12 | } 13 | println() -------------------------------------------------------------------------------- /scala/tema03/leeArchivoV1.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * script: tema03/leeArchivoV1.scala 3 | * Lectura de un archivo de texto version 1 4 | */ 5 | import scala.io.Source 6 | 7 | if(args.length >0){ 8 | for(line <- Source.fromFile(args(0)).getLines()){ 9 | println(line.length + " "+ line) 10 | } 11 | }else{ 12 | Console.err.println("Especificar una ruta valida de un archivo") 13 | } -------------------------------------------------------------------------------- /scala/tema03/leeArchivoV2.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * script: tema03/leeArchivoV2.scala 3 | * Lectura de un archivo de texto version 2 4 | */ 5 | import scala.io.Source 6 | 7 | def getLongitudNumeroLinea(s: String) = s.length.toString.length 8 | 9 | if(args.length >0){ 10 | val lineas = Source.fromFile(args(0)).getLines().toList 11 | val lineaMasLarga = lineas.reduceLeft( 12 | (a,b) => if(a.length > b.length) a else b 13 | ) 14 | val maxLongitud = getLongitudNumeroLinea(lineaMasLarga) 15 | for(linea <- lineas){ 16 | val numEspacios = maxLongitud - getLongitudNumeroLinea(linea) 17 | val padding = " " * numEspacios 18 | println(padding + linea.length + " | " + linea) 19 | } 20 | 21 | }else{ 22 | Console.err.println("Especificar una ruta valida de un archivo") 23 | } -------------------------------------------------------------------------------- /scala/tema03/sample.txt: -------------------------------------------------------------------------------- 1 | The following are the graphical (non-control) characters defined by 2 | ISO 8859-1 (1987). Descriptions in words aren't all that helpful, 3 | but they're the best we can do in text. A graphics file illustrating 4 | the character set should be available from the same archive as this 5 | file. -------------------------------------------------------------------------------- /scala/tema04/ChecksumAccumulator.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * script: tema04/CheckAccumulator.scala 3 | * Definición de una clase y su companion class 4 | */ 5 | class ChecksumAccumulator { 6 | private var sum = 0 7 | def add(b: Byte): Unit = sum += b 8 | def checksum(): Int = ~(sum & 0xFF) + 1 9 | } 10 | 11 | import scala.collection.mutable 12 | object ChecksumAccumulator { 13 | 14 | private val cache = mutable.Map.empty[String,Int] 15 | 16 | def calculate(text: String): Int ={ 17 | if(cache.contains(text)){ 18 | cache(text) 19 | }else { 20 | val acc = new ChecksumAccumulator 21 | for(c <-text){ 22 | acc.add(c.toByte) 23 | } 24 | val checksum = acc.checksum() 25 | cache += (text -> checksum) 26 | checksum 27 | } 28 | 29 | } 30 | } -------------------------------------------------------------------------------- /scala/tema04/ChecksumApp.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * script: tema04/ChecksumApp.scala 3 | * Definición de una pequeña App en Scala 4 | */ 5 | import ChecksumAccumulator.calculate 6 | object ChecksumApp { 7 | 8 | def main(args: Array[String]) = { 9 | for(arg <- args){ 10 | println(arg +" : "+ calculate(arg)) 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /scala/tema04/ChecksumTraitApp.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * script: tema04/ChecksumTraitApp.scala 3 | * Definición de una pequeña App en Scala que hace uso del trait App 4 | */ 5 | import ChecksumAccumulator.calculate 6 | object ChecksumTraitApp extends App { 7 | 8 | for(arg <- args){ 9 | println(arg +" : "+ calculate(arg)) 10 | } 11 | } -------------------------------------------------------------------------------- /scala/tema06/RationalAndThis.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * script: tema06/RationalAndThis.scala 3 | * Se agregan los métodos lessThan y max 4 | */ 5 | class Rational(n: Int, d: Int) { 6 | 7 | require(d!=0) 8 | 9 | val numerator: Int = n 10 | val denominator: Int = d 11 | 12 | override def toString = s"$numerator/$denominator" 13 | 14 | def add(r: Rational ): Rational = { 15 | // 1/5 + 2/3 = (1*3 + 2*5)/(5*3) 16 | new Rational(numerator*r.denominator + r.numerator*denominator , 17 | denominator*r.denominator) 18 | } 19 | 20 | def lessThan(otherRational: Rational) = 21 | this.numerator* otherRational.denominator < this.denominator * otherRational.numerator 22 | 23 | def max(otherRational: Rational) = 24 | if(lessThan(otherRational)) otherRational else this 25 | 26 | } -------------------------------------------------------------------------------- /scala/tema06/RationalConstructors.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * script: tema06/RationalConstructors.scala 3 | * Se agrega un constructor adicional. 4 | */ 5 | class Rational(n: Int, d: Int) { 6 | 7 | require(d!=0) 8 | 9 | val numerator: Int = n 10 | val denominator: Int = d 11 | 12 | def this(n: Int) = this(n,1) 13 | 14 | def this() = this(1) 15 | 16 | override def toString = s"$numerator/$denominator" 17 | 18 | def add(r: Rational ): Rational = { 19 | // 1/5 + 2/3 = (1*3 + 2*5)/(5*3) 20 | new Rational(numerator*r.denominator + r.numerator*denominator , 21 | denominator*r.denominator) 22 | } 23 | 24 | def lessThan(otherRational: Rational) = 25 | this.numerator* otherRational.denominator < this.denominator * otherRational.numerator 26 | 27 | def max(otherRational: Rational) = 28 | if(lessThan(otherRational)) otherRational else this 29 | 30 | } -------------------------------------------------------------------------------- /scala/tema06/RationalInvalida.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * script: tema06/RationalInvalida.scala 3 | * Este ejemplo no compila. 4 | * Las expresiones r.d y r.n son inválidas. 5 | * n y d se pueden emplear dentro del cuerpo 6 | * de la clase, pero no se crean atributos, por 7 | * lo tanto no se puede acceder a los valores 8 | * de n y d empleando al objeto r 9 | * objeto donde el método add f 10 | */ 11 | class Rational(n: Int, d: Int) { 12 | 13 | require(d!=0) 14 | override def toString = s"$n/$d" 15 | 16 | def add(r: Rational ): Rational = { 17 | // 1/5 + 2/3 = (1*3 + 2*5)/(5*3) 18 | new Rational(n*r.d + r.n*d , d*r.d) 19 | } 20 | } -------------------------------------------------------------------------------- /scala/tema06/RationalOperators.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * script: tema06/RationalOperators.scala 3 | * Se agrega un método para sumar empleado como nombre al operador + 4 | * Se agrega un método para multiplicar empleado como nombre al operador * 5 | */ 6 | class Rational(n: Int, d: Int) { 7 | 8 | require(d!=0) 9 | 10 | private val maxDivisor = mcd(n.abs,d.abs) 11 | val numerator: Int = n / maxDivisor 12 | val denominator: Int = d / maxDivisor 13 | 14 | def this(n: Int) = this(n,1) 15 | 16 | def this() = this(1) 17 | 18 | override def toString = s"$numerator/$denominator" 19 | 20 | def + (r: Rational ): Rational = { 21 | // 1/5 + 2/3 = (1*3 + 2*5)/(5*3) 22 | new Rational(numerator*r.denominator + r.numerator*denominator , 23 | denominator*r.denominator) 24 | } 25 | 26 | def * (r: Rational ): Rational = { 27 | new Rational(numerator*r.numerator,denominator*r.denominator) 28 | } 29 | 30 | 31 | def lessThan(otherRational: Rational) = 32 | this.numerator* otherRational.denominator < this.denominator * otherRational.numerator 33 | 34 | def max(otherRational: Rational) = 35 | if(lessThan(otherRational)) otherRational else this 36 | 37 | private def mcd(a: Int, b: Int): Int = 38 | if(b == 0) a 39 | else mcd(b, a%b) 40 | 41 | } -------------------------------------------------------------------------------- /scala/tema06/RationalPrivateElements.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * script: tema06/RationalPrivateElements.scala 3 | * Se agrega un atributo y método privado. 4 | * La idea de esta nueva versión es simplificar un racional empleando 5 | * su máximo común divisor mcd. Por ejemplo, 24/18 será simplificado a 4/3 6 | */ 7 | class Rational(n: Int, d: Int) { 8 | 9 | require(d!=0) 10 | 11 | private val maxDivisor = mcd(n.abs,d.abs) 12 | val numerator: Int = n / maxDivisor 13 | val denominator: Int = d / maxDivisor 14 | 15 | def this(n: Int) = this(n,1) 16 | 17 | def this() = this(1) 18 | 19 | override def toString = s"$numerator/$denominator" 20 | 21 | def add(r: Rational ): Rational = { 22 | // 1/5 + 2/3 = (1*3 + 2*5)/(5*3) 23 | new Rational(numerator*r.denominator + r.numerator*denominator , 24 | denominator*r.denominator) 25 | } 26 | 27 | def lessThan(otherRational: Rational) = 28 | this.numerator* otherRational.denominator < this.denominator * otherRational.numerator 29 | 30 | def max(otherRational: Rational) = 31 | if(lessThan(otherRational)) otherRational else this 32 | 33 | /** 34 | * Este método determina el máximo común divisor del número racional empleando 35 | * recursión. 36 | */ 37 | private def mcd(a: Int, b: Int): Int = 38 | if(b == 0) a 39 | else mcd(b, a%b) 40 | 41 | } -------------------------------------------------------------------------------- /scala/tema06/RationalValida.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * script: tema06/RationalValida.scala 3 | * Se agregan atributos para corregir el problema 4 | * del ejemplo anterior 5 | */ 6 | class Rational(n: Int, d: Int) { 7 | 8 | require(d!=0) 9 | 10 | val numerator: Int = n 11 | val denominator: Int = d 12 | 13 | override def toString = s"$numerator/$denominator" 14 | 15 | def add(r: Rational ): Rational = { 16 | // 1/5 + 2/3 = (1*3 + 2*5)/(5*3) 17 | new Rational(numerator*r.denominator + r.numerator*denominator , 18 | denominator*r.denominator) 19 | } 20 | } -------------------------------------------------------------------------------- /spring-boot/docs/t-03-logging.md: -------------------------------------------------------------------------------- 1 | # Spring boot 2 | ## 3. Logging 3 | * Internamente Spring hace uso de ```commons-logging``` , pero soporta las siguientes alternativas: 4 | * Java Util logging 5 | * Log4J2 6 | * Logback 7 | * Spring boot hace uso de la clase ```LoggingSystem```encargada de configurar logging con base a las librerías encontradas en el classpath. 8 | * Por default **Logback** es activado haciendo uso de starters. 9 | * Por default los mensajes se mandan a consola con nivel INFO, WARN, ERROR. 10 | * Para habilitar debug, trace se puede emplear ```--debug o --trace```a línea de comandos. 11 | * Adicionalmente se puede emplear el property ```debug=true o trace=true```. 12 | * Habilitar debug con estas opciones NO habilita debug para la aplicación. 13 | * Para configurar niveles y los paquetes asociados se emplean los siguientes properties: 14 | ##### Ejemplo: 15 | ```properties 16 | logging.level.root=WARN 17 | logging.level.org.springframework.web=DEBUG 18 | logging.level.org.hibernate=ERROR 19 | logging.level.com.mycompany=DEBUG 20 | #enviar mensajes a un archivo 21 | logging.path=/var/logs/mylog.log 22 | # O de forma alternativa empleando un path definido en logging.path: 23 | logging.file= mylog.log 24 | ``` 25 | * Estas propiedades evitan crear un archivo de configuración particular a cada implementación, por ejemplo: ```log4j.properties``` o ```logback.xml``` 26 | * Si se desea tener un mayor control, se pueden agregar estos archivos al classpath, spring boot los cargará automáticamente. 27 | 28 | ### 3.1 Habilitar Log4J 2 29 | * Si se desea emplear Log4J 2 en lugar de Logback, se requiere excluir ```spring-boot-starter-logging``` y agregar ```org.springframework.boot:spring-boot-starter-log4j2```: 30 | ```groovy 31 | configurations { 32 | all { 33 | exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging' 34 | } 35 | } 36 | dependencies { 37 | compile("org.springframework.boot:spring-boot-starter-log4j2") 38 | } 39 | ``` 40 | -------------------------------------------------------------------------------- /spring-boot/hola-mundo-spring-boot/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spring-boot/hola-mundo-spring-boot/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | hola-mundo-spring-boot 4 | Project hola-mundo-spring-boot created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.buildship.core.gradleprojectbuilder 15 | 16 | 17 | 18 | 19 | org.springframework.ide.eclipse.boot.validation.springbootbuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.eclipse.buildship.core.gradleprojectnature 27 | 28 | 29 | -------------------------------------------------------------------------------- /spring-boot/hola-mundo-spring-boot/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | connection.project.dir= 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /spring-boot/hola-mundo-spring-boot/.settings/org.springframework.ide.eclipse.prefs: -------------------------------------------------------------------------------- 1 | boot.validation.initialized=true 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /spring-boot/hola-mundo-spring-boot/README.md: -------------------------------------------------------------------------------- 1 | # Spring boot Hello world 2 | * Para ejecutar la aplicación: 3 | ```shell 4 | ./gradlew bootRun 5 | 6 | ``` 7 | * Abrir http://loalhost:8080 -------------------------------------------------------------------------------- /spring-boot/hola-mundo-spring-boot/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | maven { url 'https://repo.spring.io/snapshot' } 5 | maven { url 'https://repo.spring.io/milestone' } 6 | } 7 | dependencies { 8 | classpath 'org.springframework.boot:spring-boot-gradle-plugin:2.1.0.BUILD-SNAPSHOT' 9 | } 10 | } 11 | 12 | apply plugin: 'java' 13 | apply plugin: 'org.springframework.boot' 14 | apply plugin: 'io.spring.dependency-management' 15 | 16 | jar { 17 | baseName = 'hola-mundo-spring-boot' 18 | version = '0.0.1-SNAPSHOT' 19 | } 20 | 21 | repositories { 22 | jcenter() 23 | maven { url "https://repo.spring.io/snapshot" } 24 | maven { url "https://repo.spring.io/milestone" } 25 | } 26 | 27 | dependencies { 28 | compile("org.springframework.boot:spring-boot-starter-web") 29 | testCompile("org.springframework.boot:spring-boot-starter-test") 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot/hola-mundo-spring-boot/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/spring-boot/hola-mundo-spring-boot/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /spring-boot/hola-mundo-spring-boot/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip 6 | -------------------------------------------------------------------------------- /spring-boot/hola-mundo-spring-boot/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'hola-mundo-spring-boot' 2 | -------------------------------------------------------------------------------- /spring-boot/hola-mundo-spring-boot/src/main/java/com/jorgerdc/Application.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Application.java 3 | * Creation Date: 08/07/2018, 23:54:55 4 | * 5 | * Copyright (C) The Project *raven-course-spring-boot* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | 16 | package com.jorgerdc; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.boot.autoconfigure.SpringBootApplication; 20 | import org.springframework.web.bind.annotation.RequestMapping; 21 | import org.springframework.web.bind.annotation.RestController; 22 | 23 | /** 24 | * Application Main class for this project. 25 | */ 26 | @RestController 27 | @SpringBootApplication 28 | public class Application { 29 | 30 | /** 31 | * @return 32 | */ 33 | @RequestMapping("/") 34 | public String home() { 35 | return "Hello World"; 36 | } 37 | 38 | /** 39 | * @param args 40 | */ 41 | public static void main(String[] args) { 42 | SpringApplication.run(Application.class, args); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /spring-boot/parent-spring-boot/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /spring-boot/parent-spring-boot/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | parent-spring-boot 4 | Project parent-spring-boot created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.buildship.core.gradleprojectbuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.buildship.core.gradleprojectnature 16 | 17 | 18 | -------------------------------------------------------------------------------- /spring-boot/parent-spring-boot/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | connection.project.dir=properties-spring-boot 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /spring-boot/parent-spring-boot/build.gradle: -------------------------------------------------------------------------------- 1 | ext { 2 | springBootVersion ='2.1.0.BUILD-SNAPSHOT' 3 | h2Version ='1.4.197' 4 | //testing 5 | randomBeansVersion='3.7.0' 6 | } 7 | 8 | buildscript { 9 | repositories { 10 | jcenter() 11 | maven { url 'https://repo.spring.io/snapshot' } 12 | maven { url 'https://repo.spring.io/milestone' } 13 | } 14 | dependencies { 15 | classpath 'org.springframework.boot:spring-boot-gradle-plugin:2.1.0.BUILD-SNAPSHOT' 16 | } 17 | } 18 | 19 | allprojects { 20 | group = 'com.jorgerdc.tutoriales.sboot' 21 | } 22 | 23 | subprojects { 24 | 25 | apply plugin: 'java' 26 | apply plugin: 'org.springframework.boot' 27 | apply plugin: 'io.spring.dependency-management' 28 | 29 | repositories { 30 | jcenter() 31 | maven { url "https://repo.spring.io/snapshot" } 32 | maven { url "https://repo.spring.io/milestone" } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot/parent-spring-boot/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/spring-boot/parent-spring-boot/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /spring-boot/parent-spring-boot/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-bin.zip 6 | -------------------------------------------------------------------------------- /spring-boot/parent-spring-boot/properties-spring-boot/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /spring-boot/parent-spring-boot/properties-spring-boot/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | properties-spring-boot 4 | Project properties-spring-boot created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.buildship.core.gradleprojectbuilder 15 | 16 | 17 | 18 | 19 | org.springframework.ide.eclipse.boot.validation.springbootbuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.eclipse.buildship.core.gradleprojectnature 27 | 28 | 29 | -------------------------------------------------------------------------------- /spring-boot/parent-spring-boot/properties-spring-boot/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | connection.project.dir= 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /spring-boot/parent-spring-boot/properties-spring-boot/.settings/org.springframework.ide.eclipse.prefs: -------------------------------------------------------------------------------- 1 | boot.validation.initialized=true 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /spring-boot/parent-spring-boot/properties-spring-boot/application.properties: -------------------------------------------------------------------------------- 1 | #this property exists in all property files 2 | app.message=I'm at directory where the app is started level 2 3 | 4 | #this property exists only in this file 5 | app.level2=level 2 -------------------------------------------------------------------------------- /spring-boot/parent-spring-boot/properties-spring-boot/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | version = '0.0.1-SNAPSHOT' 3 | 4 | dependencies { 5 | testCompile("org.springframework.boot:spring-boot-starter-test") 6 | } -------------------------------------------------------------------------------- /spring-boot/parent-spring-boot/properties-spring-boot/config/application.properties: -------------------------------------------------------------------------------- 1 | #this property exists in all property files 2 | app.message=I'm at config directory level 1 3 | 4 | #project properties 5 | app.project.name=Awesome project 6 | 7 | app.project.projectId=100 8 | 9 | app.project.url=http://www.project.com 10 | 11 | app.project.active=true 12 | 13 | app.project.owner.name=Super man 14 | 15 | #this property exists only in this file 16 | app.level1=level 1 -------------------------------------------------------------------------------- /spring-boot/parent-spring-boot/properties-spring-boot/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/spring-boot/parent-spring-boot/properties-spring-boot/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /spring-boot/parent-spring-boot/properties-spring-boot/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-bin.zip 6 | -------------------------------------------------------------------------------- /spring-boot/parent-spring-boot/properties-spring-boot/src/main/java/application.properties: -------------------------------------------------------------------------------- 1 | #This property exists in all files 2 | app.message=I'm at classpath:/ level 4 3 | 4 | #this property exists only in this file 5 | app.level4=level 4 6 | 7 | -------------------------------------------------------------------------------- /spring-boot/parent-spring-boot/properties-spring-boot/src/main/java/com/jorgerdc/tutoriales/sboot/Application.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Application.java 3 | * Creation Date: 17/07/2018, 18:43:26 4 | * 5 | * Copyright (C) The Project *properties-spring-boot* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | 16 | package com.jorgerdc.tutoriales.sboot; 17 | 18 | import org.springframework.boot.SpringApplication; 19 | import org.springframework.boot.autoconfigure.SpringBootApplication; 20 | 21 | /** 22 | * Application start point 23 | */ 24 | @SpringBootApplication 25 | public class Application { 26 | 27 | /** 28 | * Application main method 29 | * @param args 30 | */ 31 | public static void main(String[] args) { 32 | 33 | SpringApplication.run(Application.class, args); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-boot/parent-spring-boot/properties-spring-boot/src/main/java/com/jorgerdc/tutoriales/sboot/bean/Person.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Person.java 3 | * Creation Date: 17/07/2018, 18:51:16 4 | * 5 | * Copyright (C) The Project *properties-spring-boot* Authors. 6 | * 7 | * This software was created for didactic and academic purposes. 8 | * It can be used and even modified by referring to the author 9 | * or project on GitHub. If the file is modified, add a note 10 | * after this paragraph saying that this file is a modified version. 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | */ 15 | 16 | package com.jorgerdc.tutoriales.sboot.bean; 17 | 18 | /** 19 | * POJO used to inject properties. 20 | * @See {@link Project} 21 | */ 22 | 23 | public class Person { 24 | 25 | private String name; 26 | 27 | /** 28 | * @return the name 29 | */ 30 | public String getName() { 31 | return name; 32 | } 33 | 34 | /** 35 | * @param name the name to set 36 | */ 37 | public void setName(String name) { 38 | this.name = name; 39 | } 40 | 41 | /* 42 | * See the original documentation of the method declaration 43 | * @see java.lang.Object#toString() 44 | */ 45 | @Override 46 | public String toString() { 47 | StringBuilder builder = new StringBuilder(); 48 | builder.append("Person [name="); 49 | builder.append(name); 50 | builder.append("]"); 51 | return builder.toString(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /spring-boot/parent-spring-boot/properties-spring-boot/src/main/java/config/application.properties: -------------------------------------------------------------------------------- 1 | #this property exists in all files 2 | app.message=I'm at classpath:/config directory level 3 3 | 4 | #this property exists only in this file 5 | app.level3=level 3 6 | 7 | -------------------------------------------------------------------------------- /spring-boot/parent-spring-boot/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'parent-spring-boot' 2 | include 'properties-spring-boot' -------------------------------------------------------------------------------- /typescript/docs/modulo02.md: -------------------------------------------------------------------------------- 1 | # TypeScript 2 | 3 | ## Módulo 2: TypeScript con React 4 | 5 | ReactJS es una librería de JS para construir interfaces de usuario, se puede incluir directamente como librería a nuestra aplicación y 6 | ejecutar el código de ReactJS con la ayuda de babel. Sin embargo, se puede crear una aplicación a forma de framework como una single-page 7 | application (SPA) con ayuda de un comando de npm llamado `npx`, este comando ejecuta un "atajo" de un comando en `npm`, siempre npx se 8 | instala junto con npm. 9 | 10 | Con el siguiente comando se crea una aplicacion SPA de react `npx create-react-app mi-aplicacion`, sin embargo, este comando tiene una 11 | variante para generar una aplicación SPA de react, pero basado en TypeScript: `npx create-react-app my-app --template typescript`. 12 | 13 | Se agrega un ejemplo del [tutorial](https://reactjs.org/tutorial/tutorial.html) que recomenda ReactJS, pero con 14 | una variante en [su solución en TS](../ejemplos/modulo02). 15 | 16 | Este comando genera un `package.json`, un `package-lock.json`, un `tsconfig.json` y un `node_modules`, como vimos en el módulo 01, instala 17 | las dependencias que requiere react para trabajar, además de unos cuantos scripts para empezar a trabajar. 18 | 19 | Dentro de la carpeta `public` tendremos los archivos básicos para que el html único de una SPA funcione. Dentro de la carpeta `src` 20 | tendremos los archivos de todo nuestro proyecto, aquí podemos generar nuestros componentes. Es importante mencionar que React utiliza un 21 | service worker para trabajar, un service worker es una especie de script que se ejecuta en el fondo de la aplicación, de forma separada que 22 | una página web, abriendo la puerta a interacciones que no requieren del DOM o de la interacción de usuario, se puede utilizar para push 23 | notifications, por ejemplo. 24 | 25 | ##### Fin de módulo 26 | -------------------------------------------------------------------------------- /typescript/docs/temario.md: -------------------------------------------------------------------------------- 1 | # TypeScript (4.0.x) 2 | 3 | Contenido del tutorial 4 | ## [1. Introducción a TypeScript](./modulo01.md) 5 | ### 1.1 ¿Qué es TypeScript? 6 | ### 1.2 Instalación y preparación de nuestro entorno de desarrollo 7 | ### 1.3 Sintaxis básico 8 | ### 1.4 Tipos 9 | ### 1.5 Afirmación (Assertions) 10 | ### 1.6 Variables 11 | ### 1.7 Utilidades (Number, String, Array) 12 | ### 1.8 Enumeraciones 13 | ### 1.9 Tupla vs Array 14 | ### 1.10 Interfaces y tipos 15 | ### 1.11 Unión e intersección 16 | ### 1.12 Clases 17 | ### 1.13 Namespaces 18 | 19 | ## 2. [Uso de TypeScript con React](./modulo02.md) 20 | 21 | ## 3. [Tutorial Angular CLI](../../angular/docs/temario.md) 22 | 23 | [***Liga a documentación oficial***](https://www.typescriptlang.org/docs/handbook/intro.html) 24 | 25 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo01/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | 4 | package-lock.json 5 | **/*.js 6 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo01/03-sintaxis-basico.ts: -------------------------------------------------------------------------------- 1 | export function sum(...params: number[]): number { 2 | let res = 0; 3 | for (const num of params) { 4 | res += num; 5 | } 6 | return res; 7 | } 8 | 9 | const a: number = 4; 10 | const b = { prueba: 'hola' }; 11 | const c = '5'; 12 | const d = null; 13 | const e = [1, 2, 3]; 14 | // const total = sum(a, b, c, d, e); // ERROR 15 | const total = sum(a, 1, 2, 3); // ÉXITO 16 | console.log('Resultado:', total); 17 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo01/06-variables.ts: -------------------------------------------------------------------------------- 1 | var variable1: unknown = 'string'; // : = ; 2 | let variable2: unknown; // : ; 3 | const variable3 = 'string'; // = ; 4 | var variable4; // ; 5 | variable4 = 2; 6 | variable4.toString(); 7 | variable4 = 'ASD'; 8 | variable4.toLowerCase(); 9 | 10 | var valor = 10; 11 | // const valor = 10; 12 | function unaFuncion() { 13 | var valor = 20; 14 | // let valor = 20; 15 | if (!isNaN(valor)) { 16 | var valor = 30; 17 | // const valor = 30; 18 | console.log(valor); 19 | } 20 | valor += 5; 21 | console.log(valor); 22 | } 23 | unaFuncion(); 24 | console.log(valor); 25 | 26 | const prod = (x: number, y: number): number => x * y; 27 | console.log('Arrow function:', prod(1, 2)); 28 | 29 | const usuarios: { id: string, nombre: string }[] = [ 30 | { id: '1', nombre: 'Vic' }, 31 | { id: '2', nombre: 'Sam' }, 32 | { id: '3', nombre: 'Jorge' } 33 | ]; 34 | const usuario = usuarios.find(u => u.id === '2'); // Sam 35 | const usuarioInexistente = usuarios.find(u => u.id === '5'); // undefined 36 | 37 | const miSuma: (baseValue: number, increment: number) => number = (x, y) => { 38 | return x + y; 39 | }; 40 | console.log(miSuma(2, 5)); 41 | 42 | const construyeNombre = (nombre: string, apellido?: string): string => apellido ? `${nombre} ${apellido}` : nombre; 43 | const construyeNombreFormal = (nombre:string, apellido: string, prefijo = '"Sr.'): string => `${prefijo} ${nombre} ${apellido}`; 44 | console.log(construyeNombre('Victor')); 45 | console.log(construyeNombre('Victor', 'Servin')); 46 | console.log(construyeNombreFormal('Victor', 'Servin')); 47 | console.log(construyeNombreFormal('Victor', 'Servin', 'Ing.')); 48 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo01/08-enumeraciones.ts: -------------------------------------------------------------------------------- 1 | enum Color { 2 | Red, 3 | Green, 4 | Blue 5 | } 6 | let c: Color = Color.Green; 7 | console.log(c); // 1 8 | 9 | enum Color2 { 10 | Red = 1, 11 | Green = 2, 12 | Blue = 4 13 | } 14 | let c2: Color2 = Color2.Green; 15 | console.log(c2); // 2 16 | 17 | console.log(Color[2]); // Podemos visualizar que "nombre" le corresponde al valor de una enumeración 18 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo01/09-tupla-vs-array.ts: -------------------------------------------------------------------------------- 1 | let x: [number, number, string]; 2 | x = [10, -1, 'Mi casa']; // OK 3 | // x = [10, -1, 'Mi casa', 'asd']; // Error 4 | // x = [10, 'Casa del profe']; // Error 5 | 6 | const puntos: [number, number, string][] = [ 7 | [1, 2, 'prueba 1'], 8 | [2, 3, 'prueba 2'], 9 | [3, 4, 'prueba 3'], 10 | [4, 5, 'prueba 4'] 11 | ]; 12 | 13 | puntos.forEach((p) => { 14 | // p[2].concat(p[0], p[1]); // Argument of type 'number' is not assignable to parameter of type 'string'. 15 | p[2].concat(p[0].toString(), p[1].toString()); // Válido 16 | }); 17 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo01/10-interfaces-tipos.ts: -------------------------------------------------------------------------------- 1 | interface Usuario { 2 | nombre: string; 3 | apellido: string; 4 | readonly edad: number; 5 | profesion?: string; 6 | } 7 | type FuncionNumeros = (...numeros: number[]) => number; 8 | interface Auto { 9 | color: string; 10 | marca: string; 11 | [propiedad: string]: any; 12 | } 13 | interface Animal1 { 14 | nombre: string; 15 | } 16 | interface Perro1 extends Animal1 { 17 | raza: string; 18 | } 19 | interface ClockInterface { 20 | currentTime: Date; 21 | setTime(d: Date): void; 22 | } 23 | 24 | const usuarioDePrueba: Usuario = { 25 | nombre: 'Victor', 26 | apellido: 'Servin', 27 | edad: 25 28 | }; 29 | // usuarioDePrueba.edad = usuarioDePrueba.edad + 1; // Cannot assign to 'edad' because it is a read-only property. 30 | console.log(usuarioDePrueba); 31 | console.log(usuarioDePrueba.profesion); // undefined 32 | 33 | let sumatoria: FuncionNumeros; 34 | sumatoria = (...nums) => nums.reduce((a, v) => a + v, 0); 35 | 36 | const modeloS: Auto = { 37 | color: 'negro', 38 | marca: 'Tesla', 39 | traccion: 'AWD', 40 | almacenamiento: 804, 41 | garantia: { 42 | vehiculo: true, 43 | bateria: true 44 | } 45 | }; 46 | 47 | const caramelo: Perro1 = { 48 | nombre: 'caramelo', 49 | raza: 'Boxer' 50 | }; 51 | 52 | class Reloj implements ClockInterface { 53 | currentTime: Date; 54 | 55 | constructor() { 56 | this.currentTime = new Date(); 57 | } 58 | 59 | setTime(d: Date) { 60 | this.currentTime = d; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo01/11-union-interseccion.ts: -------------------------------------------------------------------------------- 1 | interface Bird { 2 | fly(): void; 3 | layEggs(): void; 4 | } 5 | 6 | interface Fish { 7 | swim(): void; 8 | layEggs(): void; 9 | } 10 | 11 | declare function getSmallPet(): Fish | Bird; // unión 12 | 13 | let pet: Fish | Bird = getSmallPet(); 14 | pet.layEggs(); // Disponible en sus 2 posibles tipos 15 | // pet.swim(); // Solo disponible en uno de sus tipos: Property 'swim' does not exist on type 'Bird | Fish'. 16 | 17 | type NetworkLoadingState = { 18 | state: 'loading'; 19 | }; 20 | 21 | type NetworkFailedState = { 22 | state: 'failed'; 23 | code: number; 24 | }; 25 | 26 | type NetworkSuccessState = { 27 | state: 'success'; 28 | response: { 29 | title: string; 30 | duration: number; 31 | summary: string; 32 | }; 33 | }; 34 | 35 | // Creamos un tipo que representa uno de los tipos de arriba, pero aún no sabemos cual es 36 | type NetworkState = NetworkLoadingState | NetworkFailedState | NetworkSuccessState; 37 | 38 | function networkStatus(state: NetworkState): string { 39 | // console.log(state.code); // Property 'code' does not exist on type 'NetworkState'. 40 | switch (state.state) { 41 | case 'loading': 42 | return 'Descargando...'; 43 | case 'failed': 44 | return `Error ${state.code} descargando`; 45 | case 'success': 46 | return `Descargado ${state.response.title} - ${state.response.summary}`; 47 | } 48 | } 49 | 50 | interface ManejadorDeErrores { 51 | success: boolean; 52 | error?: { message: string }; 53 | } 54 | 55 | interface Articulos { 56 | articulos: { title: string }[]; 57 | } 58 | 59 | type RespuestaDeArticulos = Articulos & ManejadorDeErrores; 60 | 61 | const handler = (response: RespuestaDeArticulos) => { 62 | if (response.error) { 63 | console.log(response.error.message); 64 | throw response.error; 65 | } 66 | console.log(response.articulos); 67 | }; 68 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo01/13-1-namespaces.ts: -------------------------------------------------------------------------------- 1 | namespace Validation { 2 | const lettersRegexp = /^[A-Za-z]+$/; 3 | const numberRegexp = /^[0-9]+$/; 4 | 5 | export interface StringValidator { 6 | isAcceptable(s: string): boolean; 7 | } 8 | 9 | export class LettersOnlyValidator implements StringValidator { 10 | isAcceptable(s: string) { 11 | return lettersRegexp.test(s); 12 | } 13 | } 14 | 15 | export class ZipCodeValidator implements StringValidator { 16 | isAcceptable(s: string) { 17 | return s.length === 5 && numberRegexp.test(s); 18 | } 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo01/13-2-namespaces.ts: -------------------------------------------------------------------------------- 1 | /// 2 | // Para compilar este archivo se ejecuta en el módulo raiz: tsc --outFile dist/13-namespaces.js 13-2-namespaces.ts 3 | 4 | let strings = ['Hello', '98052', '101']; // Cadenas a validar 5 | 6 | // Validadores a usar 7 | let validators: { [s: string]: Validation.StringValidator } = {}; 8 | validators['ZIP code'] = new Validation.ZipCodeValidator(); 9 | validators['Letters only'] = new Validation.LettersOnlyValidator(); 10 | 11 | // Muestra si cada cadena pasa cada validador. 12 | for (const s of strings) { 13 | for (const name of Object.keys(validators)) { 14 | console.log(`"${s}" - ${validators[name].isAcceptable(s) ? 'matches' : 'does not match'} ${name}`); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo01/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tutoriales-modulo01", 3 | "version": "1.0.0", 4 | "description": "Paquetes de ejemplo para el tutorial de typescript", 5 | "main": "index.js", 6 | "scripts": { 7 | "build": "tsc && npm run build:namespace", 8 | "build:namespace": "tsc --outFile dist/13-namespaces.js 13-1-namespaces.ts 13-2-namespaces.ts", 9 | "run:namespace": "tsc --outFile dist/13-namespaces.js 13-1-namespaces.ts 13-2-namespaces.ts && node dist/13-namespaces.js" 10 | }, 11 | "author": "vservin", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "tslint": "^6.1.3", 15 | "typescript": "^4.0.2" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo01/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "moduleResolution": "node", 5 | "noImplicitAny": true, 6 | "target": "es6", 7 | "typeRoots": [ 8 | "node_modules/@types" 9 | ], 10 | "lib": [ 11 | "es5", 12 | "es2015.promise", 13 | "dom", 14 | "es2015" 15 | ], 16 | "allowSyntheticDefaultImports": true, 17 | "declaration": false, 18 | "allowJs": true, 19 | "strict": true, 20 | "noEmitOnError": true, 21 | "outDir": "dist", 22 | "removeComments": true 23 | }, 24 | "exclude": [ 25 | "dist", 26 | "node_modules", 27 | "13-1-namespaces.ts", 28 | "13-2-namespaces.ts" 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo01/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["./tslint.airbnb.json", "tslint:recommended"], 3 | "rules": { 4 | "ter-indent": false, 5 | "prefer-const": [true], 6 | "no-var-keyword": true, 7 | "prefer-template": true, 8 | "no-inferrable-types": true, 9 | "space-before-function-paren": false, 10 | "trailing-comma": [true, { 11 | "singleline": "never", 12 | "multiline": { 13 | "objects": "never", 14 | "arrays": "never", 15 | "functions": "never", 16 | "typeLiterals": "ignore" 17 | } 18 | }], 19 | "arrow-return-shorthand": true, 20 | "max-line-length": [true, 140], 21 | "no-console": [true, "warn", "error"], 22 | "no-debugger": true, 23 | "no-duplicate-super": true, 24 | "no-duplicate-switch-case": true, 25 | "variable-name": [true, "check-format", "allow-leading-underscore"], 26 | "no-empty": true, 27 | "no-irregular-whitespace": true, 28 | "no-increment-decrement": false, 29 | "no-sparse-arrays": true, 30 | "no-magic-numbers": [true, -1, 0, 1, 2, 3, 4, 5, 6, 10, 100, 1000], 31 | "quotemark": [true, "single"], 32 | "max-classes-per-file": false, 33 | "no-namespace": false, 34 | "no-reference": false 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo02/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | package-lock.json 25 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo02/README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 2 | 3 | ## Available Scripts 4 | 5 | In the project directory, you can run: 6 | 7 | ### `npm start` 8 | 9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 11 | 12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console. 14 | 15 | ### `npm test` 16 | 17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 19 | 20 | ### `npm run build` 21 | 22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance. 24 | 25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed! 27 | 28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 29 | 30 | ### `npm run eject` 31 | 32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 33 | 34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 35 | 36 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 37 | 38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 39 | 40 | ## Learn More 41 | 42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 43 | 44 | To learn React, check out the [React documentation](https://reactjs.org/). 45 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo02/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-app", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^4.2.4", 7 | "@testing-library/react": "^9.5.0", 8 | "@testing-library/user-event": "^7.2.1", 9 | "@types/jest": "^24.9.1", 10 | "@types/node": "^12.12.55", 11 | "@types/react": "^16.9.49", 12 | "@types/react-dom": "^16.9.8", 13 | "react": "^16.13.1", 14 | "react-dom": "^16.13.1", 15 | "react-scripts": "3.4.3", 16 | "typescript": "^3.7.5" 17 | }, 18 | "scripts": { 19 | "start": "react-scripts start", 20 | "build": "react-scripts build", 21 | "test": "react-scripts test", 22 | "eject": "react-scripts eject" 23 | }, 24 | "eslintConfig": { 25 | "extends": "react-app" 26 | }, 27 | "browserslist": { 28 | "production": [ 29 | ">0.2%", 30 | "not dead", 31 | "not op_mini all" 32 | ], 33 | "development": [ 34 | "last 1 chrome version", 35 | "last 1 firefox version", 36 | "last 1 safari version" 37 | ] 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo02/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/typescript/ejemplos/modulo02/public/favicon.ico -------------------------------------------------------------------------------- /typescript/ejemplos/modulo02/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo02/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/typescript/ejemplos/modulo02/public/logo192.png -------------------------------------------------------------------------------- /typescript/ejemplos/modulo02/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jorgerdc/tutoriales/6ee6294ba64dfb20800466610cf0d03208e5123f/typescript/ejemplos/modulo02/public/logo512.png -------------------------------------------------------------------------------- /typescript/ejemplos/modulo02/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo02/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo02/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | 15 | #root { 16 | display: flex; 17 | justify-content: center; 18 | margin-top: 10rem; 19 | } 20 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo02/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import * as serviceWorker from './serviceWorker'; 5 | import Game from './tic-tac-toe/game'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ); 13 | 14 | // If you want your app to work offline and load faster, you can change 15 | // unregister() to register() below. Note this comes with some pitfalls. 16 | // Learn more about service workers: https://bit.ly/CRA-PWA 17 | serviceWorker.unregister(); 18 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo02/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo02/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo02/src/tic-tac-toe/board.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Square from './square'; 3 | import { SquareValues } from './game'; 4 | 5 | interface BoardProperties { 6 | squares: SquareValues[]; 7 | onClick: (i: number) => void; 8 | } 9 | 10 | class Board extends React.Component { 11 | 12 | renderSquare(i: any): JSX.Element { 13 | return this.props.onClick(i)} />; 14 | } 15 | 16 | render(): JSX.Element { 17 | return ( 18 |
19 |
20 | {this.renderSquare(0)} 21 | {this.renderSquare(1)} 22 | {this.renderSquare(2)} 23 |
24 |
25 | {this.renderSquare(3)} 26 | {this.renderSquare(4)} 27 | {this.renderSquare(5)} 28 |
29 |
30 | {this.renderSquare(6)} 31 | {this.renderSquare(7)} 32 | {this.renderSquare(8)} 33 |
34 |
35 | ); 36 | } 37 | } 38 | 39 | export default Board; 40 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo02/src/tic-tac-toe/game.css: -------------------------------------------------------------------------------- 1 | body { 2 | font: 14px "Century Gothic", Futura, sans-serif; 3 | margin: 20px; 4 | } 5 | 6 | ol, ul { 7 | padding-left: 30px; 8 | } 9 | 10 | .board-row:after { 11 | clear: both; 12 | content: ""; 13 | display: table; 14 | } 15 | 16 | .status { 17 | margin-bottom: 10px; 18 | } 19 | 20 | .square { 21 | background: #fff; 22 | border: 1px solid #999; 23 | float: left; 24 | font-size: 24px; 25 | font-weight: bold; 26 | line-height: 34px; 27 | height: 34px; 28 | margin-right: -1px; 29 | margin-top: -1px; 30 | padding: 0; 31 | text-align: center; 32 | width: 34px; 33 | } 34 | 35 | .square:focus { 36 | outline: none; 37 | } 38 | 39 | .kbd-navigation .square:focus { 40 | background: #ddd; 41 | } 42 | 43 | .game { 44 | display: flex; 45 | flex-direction: row; 46 | } 47 | 48 | .game-info { 49 | margin-left: 20px; 50 | } 51 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo02/src/tic-tac-toe/square.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | interface SquareProperties { 4 | value: any; 5 | onClick: () => void; 6 | } 7 | 8 | function Square(props: SquareProperties): JSX.Element { 9 | return ( 10 | 13 | ); 14 | } 15 | 16 | export default Square; 17 | -------------------------------------------------------------------------------- /typescript/ejemplos/modulo02/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "module": "esnext", 16 | "moduleResolution": "node", 17 | "resolveJsonModule": true, 18 | "isolatedModules": true, 19 | "noEmit": true, 20 | "jsx": "react" 21 | }, 22 | "include": [ 23 | "src" 24 | ] 25 | } 26 | --------------------------------------------------------------------------------