DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Curious about the future of data-driven systems? Join our Data Engineering roundtable and learn how to build scalable data platforms.

Data Engineering: The industry has come a long way from organizing unstructured data to adopting today's modern data pipelines. See how.

Threat Detection: Learn core practices for managing security risks and vulnerabilities in your organization — don't regret those threats!

Managing API integrations: Assess your use case and needs — plus learn patterns for the design, build, and maintenance of your integrations.

Avatar

Dror Helper

Senior consultant at CodeValue

Qiryat Ono, IL

Joined Nov 2009

About

Dror Helper is an experienced software developer has written and designed software in various fields including video streaming, eCommerce, performance optimization and unit testing tools. He is passionate about programming best practices and all things software development, and has been a guest presenter at several user group meetings and ALT.NET events. Dror's blog can be found at http://blog.drorhelper.com where he writes about unit testing, agile methodologies, development tools, programming languages and anything else he finds interesting.

Stats

Reputation: 457
Pageviews: 593.9K
Articles: 7
Comments: 16
  • Articles
  • Comments

Articles

article thumbnail
Versioning Multiple Microservices in a Monorepo Using Maven
Let's make microservices a bit less complicated.
January 24, 2021
· 6,704 Views · 3 Likes
article thumbnail
Better Tests Names Using JUnit's Display Name Generators
Writing unit tests can be challenging, but there is one thing that can get you on the right track — the test name.
September 14, 2020
· 9,136 Views · 3 Likes
article thumbnail
Using C# Anonymous Types to Assert Complex Results in Your Unit Tests
A developer gives a tutorial on how to perform unit testing on web applications using the C# language and anonymous types in his code.
July 1, 2019
· 15,819 Views · 1 Like
article thumbnail
Comparing Two Objects Using Assert.AreEqual()
In order to change the way two objects are compared in an assert we only need change the behavior of one of them — the expect value.
March 30, 2016
· 109,540 Views · 2 Likes
article thumbnail
When Mockito’s InjectMocks Does Not Inject Mocks
How to perform unit tests in Java using Mockito's InjectMocks tool and how to get it working.
December 3, 2015
· 86,036 Views · 9 Likes
article thumbnail
call_once for C#
One of the useful gems that made it into C++11 Standard Template Libraries (STD) is call_once, this nifty little method makes sure that specific code is called only once (duh) and it follows these 3 rules: Exactly one execution of exactly one of the functions (passed as f to the invocations in the group) is performed. It is undefined which function will be selected for execution. The selected function runs in the same thread as thecall_once invocation it was passed to. No invocation in the group returns before the abovementioned execution of the selected function is completed successfully, that is, doesn't exit via an exception. If the selected function exits via exception, it is propagated to the caller. Another function is then selected and executed. I needed something similar – I had a method that should only be called once (initialize) and I wanted to implement something similar to the call_once I’ve been using for my C++ development. My first object was to try and make it as preferment as possible and so I’ve looked for a solution that does not involve locks: public static class Call { public static void Once(OnceFlag flag, Action action) { if (flag.CheckIfNotCalledAndSet) { action.Invoke(); } } } since I was trying to mimic the C++ code I wrote two objects Call (above) and OnceFlag which has all of the magic inside using Interlocked: public class OnceFlag { private const int NotCalled = 0; private const int Called = 1; private int _state = NotCalled; internal bool CheckIfCalledAndSet { get { var prev = Interlocked.Exchange(ref _state, Called); return prev == NotCalled; } } internal void Reset() { Interlocked.Exchange(ref _state, NotCalled); } } I’m using Interlocked as a thread-safe way to check & set the value making sure that only once it would return true – try it: class Program { static OnceFlag _flag = new OnceFlag(); static void Main(string[] args) { var t1 = new Thread(() => DoOnce(1)); var t2 = new Thread(() => DoOnce(2)); var t3 = new Thread(() => DoOnce(3)); var t4 = new Thread(() => DoOnce(4)); t1.Start(); t2.Start(); t3.Start(); t4.Start(); t1.Join(); t2.Join(); t3.Join(); t4.Join(); } private static void DoOnce(int index) { Call.Once(_flag, () => Console.WriteLine("Callled (" + index + ")")); } } It’s very simple solution unfortunately not entirely correct – the method used will only be called once, but requirements 2 & 3 were not implemented. Luckily for me I didn’t need to make sure that exception enable another call to pass through nor did I need to block other calls until the first call finishes. But I wanted to try and write a proper implementation, unfortunately not as preferment due to the use of locks: public static void Once(OnceFlagSimple flag, Action action) { lock (flag) { if (flag.CheckIfNotCalled) { action.Invoke(); flag.Set(); } } } But it works, and since I’m already using lock I can split the check and Set methods and use a bool value inside the flag instead of Interlocked. All other threads are blocked due to lock until first finish running – check! In case of exception other method can execute the once block – check! If exited properly the block would only execute once – check! But not very good performance due to locking even after the first time run. I’m still looking for a better way to implement call_once – it’s a good exercise in threading and I might find a cool new ways to use the classes under Threading or Task namespaces. please let me know if you have a better implementation – that’s what the comments are for…
March 6, 2014
· 6,444 Views
article thumbnail
Tip: Using Notepad++ to Read Log Files
I had to read a log file containing a few hundred lines today at work. My first instinct was to open it using my trusty Notepad++.
June 13, 2013
· 65,743 Views · 1 Like

Comments

Versioning Multiple Microservices in a Monorepo Using Maven

Jan 25, 2021 · Mike Gates

Actually there are good reasons to have all of your services in the same repository as many as using multiple repositories, regardless many teams use monrepo either by choice or not and should have proper versioning and deployment plans.




Whats NetBeans 6.7 got for Groovy and Grails?

Feb 12, 2015 · Mr B Loid

NP


Where should I add my implementation?

Whats NetBeans 6.7 got for Groovy and Grails?

Feb 12, 2015 · Mr B Loid

NP


Where should I add my implementation?

Whats NetBeans 6.7 got for Groovy and Grails?

Feb 12, 2015 · Mr B Loid

NP


Where should I add my implementation?

Whats NetBeans 6.7 got for Groovy and Grails?

Feb 12, 2015 · Mr B Loid

NP


Where should I add my implementation?

Whats NetBeans 6.7 got for Groovy and Grails?

Feb 07, 2015 · Mr B Loid

Sure,

You can add my solution - just add credits to the original post (http://blog.drorhelper.com/2015/02/fizzbuzz-tdd-kata-using-reactive.html)



Whats NetBeans 6.7 got for Groovy and Grails?

Feb 07, 2015 · Mr B Loid

Sure,

You can add my solution - just add credits to the original post (http://blog.drorhelper.com/2015/02/fizzbuzz-tdd-kata-using-reactive.html)



Whats NetBeans 6.7 got for Groovy and Grails?

Feb 07, 2015 · Mr B Loid

Sure,

You can add my solution - just add credits to the original post (http://blog.drorhelper.com/2015/02/fizzbuzz-tdd-kata-using-reactive.html)



Whats NetBeans 6.7 got for Groovy and Grails?

Feb 07, 2015 · Mr B Loid

Sure,

You can add my solution - just add credits to the original post (http://blog.drorhelper.com/2015/02/fizzbuzz-tdd-kata-using-reactive.html)



Designer + Developer + JavaFX

Jun 15, 2013 · Mr B Loid

Have you selected the new "language" from the languages menu?

Also make sure the works have the correct case as the syntax is case sensitive by defualt.

Tip: Using Notepad++ to Read Log Files

Jun 15, 2013 · Eric Gregory

Have you selected the new "language" from the languages menu?

Also make sure the works have the correct case as the syntax is case sensitive by defualt.

Tip: Using Notepad++ to Read Log Files

Jun 15, 2013 · Eric Gregory

Have you selected the new "language" from the languages menu?

Also make sure the works have the correct case as the syntax is case sensitive by defualt.

Designer + Developer + JavaFX

Jun 15, 2013 · Mr B Loid

Have you selected the new "language" from the languages menu?

Also make sure the works have the correct case as the syntax is case sensitive by defualt.

Netbeans 6.0 Daily Build - new logo, new splash, is faster

May 03, 2011 · adam bien

You almost got it - Actually the bug is access to a modified closure. By the time the delegate (lambda) is executed, the "client" variable will not be the one passed into the lambda. You can see the answers on my blog
Netbeans 6.0 Daily Build - new logo, new splash, is faster

May 03, 2011 · adam bien

You almost got it - Actually the bug is access to a modified closure. By the time the delegate (lambda) is executed, the "client" variable will not be the one passed into the lambda. You can see the answers on my blog
Netbeans 6.0 Daily Build - new logo, new splash, is faster

May 03, 2011 · adam bien

You almost got it - Actually the bug is access to a modified closure. By the time the delegate (lambda) is executed, the "client" variable will not be the one passed into the lambda. You can see the answers on my blog

User has been successfully modified

Failed to modify user

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: