lunes, 7 de noviembre de 2022

martes, 1 de noviembre de 2022

UML Associations

 UML Associations

 
 
Generating UML from an aggregation association using intelij plugin uses a filled diamond, this is not correct because the aggregation is represented by an empty diamon, in deed, all the aggregation relations or composition relations are represented by a filled diamond. 

   Java can not destroy an entity so when the owner of a relationship deads this can not destroy the entity associated to it. This means that composition associations can not be represented by java nor his UML representation.
 
 
This is the same java code but generated from ObjectAid plugin in Eclipse. This not shows the filled diamond, even does not represent any diamond. The association correspond to an aggregation but the tool don´t shows the empty diamond.
The Next Association is a bidirectional association of the Class Person
 
// Association
// Person ----------- Person bidirectional association, both has his own life cycle.
personA.setConnectWith( personB);
personB.setConnectWith( personA)
 
On the ObjectAid Tool the relation is shown by an arrow pointing to the Person Class itself. But in case of the tool on InteliJ this self relation can not be displayed.








 
 
eot

martes, 25 de octubre de 2022

SOLID principles

SOLID principles

 

Single Responsability Principle

bla bla
 
 blabla
 
blabla
  Responsability of change, source of change accord to different domains,  for example CFO, COO, CTO
 

 
Many ways to separate the inference. using concrete classes. by multiple inheritance ( not allowed in java) but could use interfaces.  using facade ...
 



Open/Close Principle

 
bla bla
 

Example 2

 
Adding a new operation class, forces Calculator Class to be modified.

 
With the Refactor, adding a new operation class the Calculator Class is not modified.



 

Liskov Principle

 
blabla




Interface Segregation Principle


bla bla
 


 

Dependency Inversion Principle

bla bla





eot

domingo, 31 de julio de 2022

Git Clone Repo Preserving History

 Git Clone Repo Preserving History

reference
https://docs.github.com/en/repositories/creating-and-managing-repositories/duplicating-a-repository

Repository Origin account: jalbertomr
https://github.com/jalbertomr/project-reactor-essentials-test


New Destiny Repository (To be reated in another account)  account: cuentafulana
create new Repository: cuentafulana/clonedRepoTest

1.- Create New Repository on the account where the Repository will be cloned



2.- Invite te original account to be a collaborator sending an invitation



Settings -> Collaborators





The invitation has been done, now the Account of the Source Repository has to accept the collaboration invitation.




3.- The Account of the Source Repository accepts the invitation in order to to push on the empty cloned repository




 https://github.com/cuentafulana/clonedRepoTest
 Now the source account can do push to the cloned Repository of the other account.


4.- Mirroring the repository, open git bash.

5.- Create a bare clone of the repository

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab
$ git clone --bare https://github.com/jalbertomr/project-reactor-essentials-test
Cloning into bare repository 'project-reactor-essentials-test.git'...
remote: Enumerating objects: 603, done.
remote: Counting objects: 100% (603/603), done.
remote: Compressing objects: 100% (118/118), done.
remote: Total 603 (delta 149), reused 598 (delta 144), pack-reused 0
Receiving objects: 100% (603/603), 128.95 KiB | 1.08 MiB/s, done.
Resolving deltas: 100% (149/149), done.


6.- Mirror push to the new repository

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab
$ ls
project-reactor-essentials-test.git/

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab
$ cd project-reactor-essentials-test.git

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab/project-reactor-essentials-test.git (BARE:master)
$ git push --mirror https://github.com/cuentafulana/clonedRepoTest
Enumerating objects: 603, done.
Counting objects: 100% (603/603), done.
Delta compression using up to 12 threads
Compressing objects: 100% (113/113), done.
Writing objects: 100% (603/603), 128.95 KiB | 18.42 MiB/s, done.
Total 603 (delta 149), reused 603 (delta 149)
remote: Resolving deltas: 100% (149/149), done.
To https://github.com/cuentafulana/clonedRepoTest
 * [new branch]      master -> master

7.- Remove the temporary local repository you created earlier, If apply.

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab
$ rm -rf project-reactor-essentials-test.git

8.- Check the creation of the mirrored repository in the non original account


 It has the files and his commits

9.- Now modify the README.md file to indicate that this repository is a mirrored one.

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab
$ git clone https://github.com/cuentafulana/clonedRepoTest
Cloning into 'clonedRepoTest'...
remote: Enumerating objects: 603, done.
remote: Counting objects: 100% (603/603), done.
remote: Compressing objects: 100% (113/113), done.
Receiremote: Total 603 (delta 149), reused 603 (delta 149), pack-reused 0
Receiving objects: 100% (603/603), 128.95 KiB | 956.00 KiB/s, done.
Resolving deltas: 100% (149/149), done.

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab
$ dir
clonedRepoTest

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab
$ cd clonedRepoTest

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab/clonedRepoTest (master)
$ git branch Feature-clone

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab/clonedRepoTest (master)
$ git checkout Feature-clone
Switched to branch 'Feature-clone'

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab/clonedRepoTest (Feature-clone)
$ ls
data.txt  pom.xml  project-reactor-essentials.iml  README.md  src/  target/

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab/clonedRepoTest (Feature-clone)
$ nano README.md

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab/clonedRepoTest (Feature-clone)
$ git add README.md

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab/clonedRepoTest (Feature-clone)
$ git commit -m "this is a mirrored reposiotry in README.md"
[Feature-clone 438d19b] this is a mirrored reposiotry in README.md
 1 file changed, 1 insertion(+), 1 deletion(-)

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab/clonedRepoTest (Feature-clone)
$ git status
On branch Feature-clone
nothing to commit, working tree clean

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab/clonedRepoTest (Feature-clone)
$ git remote
origin

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab/clonedRepoTest (Feature-clone)
$ git push
fatal: The current branch Feature-clone has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin Feature-clone


bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab/clonedRepoTest (Feature-clone)
$ git push --set-upstream origin Feature-clone
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 343 bytes | 343.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
remote:
remote: Create a pull request for 'Feature-clone' on GitHub by visiting:
remote:      https://github.com/cuentafulana/clonedRepoTest/pull/new/Feature-clone
remote:
To https://github.com/cuentafulana/clonedRepoTest
 * [new branch]      Feature-clone -> Feature-clone
Branch 'Feature-clone' set up to track remote branch 'Feature-clone' from 'origin'.

10.- Now Cloned Mirrored Repository has the new branch feature-clone (2 branches)



 
11.- Let´s protect the master branch in order that a pull Request is required before merging







12.- Let´s check the difference between branches

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab/clonedRepoTest (master)
$ git diff master Feature-clone
diff --git a/README.md b/README.md
index a5a4453..1e4b134 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# Project Reactor Essentials Tests
+# Project Reactor Essentials Tests (this is a mirrored Repository)
 A Walk through Project Reactor with test


13.- Let´s merge the branch Feature-clone into master

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab/clonedRepoTest (master)
$ git merge Feature-clone
Updating d801901..438d19b
Fast-forward
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


14.- Now we can se the change on master - READMEmd file

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab/clonedRepoTest (master)
$ head README.md
# Project Reactor Essentials Tests (this is a mirrored Repository)
A Walk through Project Reactor with test


- Dependencies
- setup Tests
- Mono.just, subscribe(), log()
- subscribe( Consumer, errorConsumer)
- subscribe( Consumer, errorConsumer, CompleteConsumer)
- subscribe( Consumer, errorConsumer, CompleteConsumer, subscriptionConsumer)

15.- Now let´s push the master branch to the repository

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab/clonedRepoTest (master)
$ git push -u origin master
Total 0 (delta 0), reused 0 (delta 0)
remote: error: GH006: Protected branch update failed for refs/heads/master.
remote: error: At least 1 approving review is required by reviewers with write access.
To https://github.com/cuentafulana/clonedRepoTest
 ! [remote rejected] master -> master (protected branch hook declined)
error: failed to push some refs to 'https://github.com/cuentafulana/clonedRepoTest'

We protect the master branch, so we need a pull Request and approval, so the push is not completed.

16.- Create a Pull Request master <-- Feature-clone




On the another account appears the pull request requiring aproval




Commented and closed pull request


ReOpen and Add your review


Review Changes -- Approve


Submit review


Now we can do the push

bext@DESKTOP-NLF0058 MINGW64 /e/CloneRepoLab/clonedRepoTest (master)
$ git push -u origin master
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/cuentafulana/clonedRepoTest
   d801901..438d19b  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.




In the Account of the cloned Repository the change on the master branch of the README.md file is visible


Other simple operations


$git status
$git branch -a
#create new branch
$git branch new-branch-name
#change environment to the new branch
$git checkout new-branch-name
 
Git checkout Remote Branch
#create a new branch
$git branch new-branch-name
#change environment to the new branch
$git checkout new-branch-name
#create a change
$touch change.txt
#commit the change
$git add .
$git commit -m "add a new change"
#push to a new branch
$git push --set-upstream origin new-branch

Git Checkout new branch

#fetch all remote branches
$git fetch origin
#list all branches
$git branch -a
#Pull Changes to a Remote Branch
$git checkout -b remote-branch origin/remote-branch

with the remote branch active, do another change
$touch anotherChange.txt
$git add .
$git commit -m "another change"
$git push

git push origin/remote-branch commando was not necessary

eot