diff --git a/component-object/README.md b/component-object/README.md new file mode 100644 index 000000000..7619ed121 --- /dev/null +++ b/component-object/README.md @@ -0,0 +1,25 @@ +--- +layout: pattern +title: Component Object +folder: component-object +permalink: /patterns/component-object/ +categories: Testing +tags: + - Java + - Difficulty-Intermediate +--- + +## Intent +Web development is shifting more and more towards reusable components. Frameworks like React, Polymer, Angular etc. provide various component friendly abstractions to make front-end code-bases more maintainable. So our web applications are now full of “widgets” that have same behavior. We can use component various times on single web page or re-use it on various web pages. Therefore it is logical to create abstraction which covers functionality of single component and reuse it across end-to-end tests. + +![alt text](./etc/component-object.png "Component Object Pattern") + +## Applicability +Use the Component Object Pattern in the following situations: + +* When you have various same components on single web page and you need to test the web page +* When you have multiple web pages using same component abstractions and you need to test the web pages + +## Credits + +* [Component Object](https://lkrnac.net/blog/2016/10/component-object-pattern-example/) diff --git a/component-object/etc/component-object.png b/component-object/etc/component-object.png new file mode 100644 index 000000000..22118fef3 Binary files /dev/null and b/component-object/etc/component-object.png differ diff --git a/component-object/etc/component-object.ucls b/component-object/etc/component-object.ucls new file mode 100644 index 000000000..ed3ffe2ee --- /dev/null +++ b/component-object/etc/component-object.ucls @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/monitor-object/README.md b/monitor-object/README.md new file mode 100644 index 000000000..45abaa26b --- /dev/null +++ b/monitor-object/README.md @@ -0,0 +1,27 @@ +--- +layout: pattern +title: Monitor Object +folder: monitor-object +permalink: /patterns/monitor-object/ +categories: Concurrency +tags: + - Java + - Difficulty-Intermediate +--- + +## Intent +In 1974, Tony Hoare proposed the concept of monitors for designing and reasoning about objects that are shared between multiple threads. The key property of these "Hoare-style" monitors is that threads can wait until some specific assertion about the monitor's state is true and be guaranteed that it is still true after the thread has been awakened. The purpose of the Monitor Object is to provide an implementation of Hoare-style monitors for thread communication in a Java-based monitor package that automates assertion checking during execution. This approach reduces redundant coding and automates assertions checking during execution. + +![alt text](./etc/monitor-object.png "Monitor Object Pattern") + +## Applicability +Use the Monitor Object Pattern for thread signaling (over Java's wait() and notify() approach) in the following situations: + +* When you need Defensive programming in multithreaded code - The monitor package provides support for defensive programming through the invariant() method and the assertion objects associated with each condition object. Java's notify() and wait() provide no assertion checking +* When you need objects to wait on multiple wait queues - The monitor package provides condition objects, each providing its own wait queue. Threads waiting for different assertions to become true wait on different queues. Using wait(), there is only one wait queue per object. +* When you need seamless passing of occupancy - In the monitor package, control is passed seamlessly from the signaling thread to an awaiting thread. You can be sure that, after returning from an await(), the assertion the thread has waited for is true. In contrast, the notify() and notifyAll() methods simply move a waiting thread back to the entry queue for the monitor. + +## Credits + +* [Theodore S. Norvell - Monitor Object](https://www.javaworld.com/article/2077769/core-java/better-monitors-for-java.html) +* [Monitor (syncronization)](https://en.wikipedia.org/wiki/Monitor_(synchronization)) diff --git a/monitor-object/etc/monitor-object.png b/monitor-object/etc/monitor-object.png new file mode 100644 index 000000000..a6d736894 Binary files /dev/null and b/monitor-object/etc/monitor-object.png differ diff --git a/monitor-object/etc/monitor-object.ucls b/monitor-object/etc/monitor-object.ucls new file mode 100644 index 000000000..fd7c113f5 --- /dev/null +++ b/monitor-object/etc/monitor-object.ucls @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file