Sign Up Now!

Sign up and get personalized intelligence briefing delivered daily.


Sign Up

Articles related to "method"


Ruby Concepts - Singleton Classes

  • Have you ever been talking to someone or reading a blog post and "singleton class" or "singleton method" got used, and you just smile and nod, making a mental note to look it up later?
  • There are, however, a couple more interesting details that I thought were cool that are sort of tangentially related: the somewhat hard to decipher class << self syntax, the different ways of creating class methods, and the use of extend.
  • There are actually two ways to use the class keyword: directly followed by a constant (a la class Gelato), or followed by the "shovel operator" and an object (a la class << momo).
  • Let's focus on the second one, which is the syntax to directly open up an object's singleton class.
  • The difference, however, is that extend puts these methods onto the target object's singleton class.

save | comments | report | share on


Introduction to Unit Testing with Java

  • For the sake of this post, we will not be applying TDD (Test Driven-Development) techniques, our focus will be on getting to know how to write test classes and methods.
  • So, in order for us to start, we will need to create a class inside our src/test/java/ directory, and name it MathTests.
  • The use of the suffix "Tests" at the end of a testing class name is a common naming convention that will allow other developers and yourself to quickly know, without opening the file, that it has testing logic inside of it.
  • Let's change the act part so it adds 3 and 2 together, so our actual value becomes 5 and our test should fail.
  • Tip: most of the time we should only use 1 single Assert method per test, although there are exceptions to this rule.

save | comments | report | share on


Java is Pass-by-Value, Dammit

  • I'm really tired of hearing folks (incorrectly) state "primitives are passed by value, objects are passed by reference".
  • In Java, Objects are passed by reference, and primitives are passed by value.
  • Everyone can easily agree that primitives are passed by value; there's no such thing in Java as a pointer/reference to a primitive.
  • The value of a pointer is often the memory address of the data you're interested in.
  • The word "reference" in programming language design originally comes from how you pass data to subroutines/functions/procedures/methods.
  • myDog still has the value 42; it's still pointing to the original Dog. It's perfectly valid to follow an address and change what's at the end of it; that does not change the variable, however.
  • If Java had pass-by-reference semantics, the foo method we defined above would have changed where myDog was pointing when it assigned someDog on line BBB.

save | comments | report | share on


Artificial intelligence accelerates discovery of metallic glass - Northwestern Now

  • Now a group led by scientists at Northwestern University, the Department of Energy’s SLAC National Accelerator Laboratory and the National Institute of Standards and Technology (NIST) has reported a shortcut for discovering and improving metallic glass — and, by extension, other elusive materials — at a fraction of the time and cost.
  • The research group took advantage of a system at SLAC’s Stanford Synchrotron Radiation Lightsource (SSRL) that combines machine learning — a form of artificial intelligence where computer algorithms glean knowledge from enormous amounts of data — with experiments that quickly make and screen hundreds of sample materials at a time.
  • The team said the method will be useful in all kinds of experiments, especially in searches for materials like metallic glass and catalysts whose performance is strongly influenced by the way they’re manufactured, and those where scientists don’t have theories to guide their search.

save | comments | report | share on


Artificial intelligence accelerates discovery of metallic glass

  • Now a group led by scientists at Northwestern University, the Department of Energy’s SLAC National Accelerator Laboratory and the National Institute of Standards and Technology (NIST) has reported a shortcut for discovering and improving metallic glass — and, by extension, other elusive materials — at a fraction of the time and cost.
  • The research group took advantage of a system at SLAC’s Stanford Synchrotron Radiation Lightsource (SSRL) that combines machine learning — a form of artificial intelligence where computer algorithms glean knowledge from enormous amounts of data — with experiments that quickly make and screen hundreds of sample materials at a time.
  • The team said the method will be useful in all kinds of experiments, especially in searches for materials like metallic glass and catalysts whose performance is strongly influenced by the way they’re manufactured, and those where scientists don’t have theories to guide their search.

save | comments | report | share on


Learn Dart before you Flutter

  • Given the ‘gold rush’ of technological innovations targeting the mobile space, developing mobile apps have never been easier, thanks to cross-platform solutions like Flutter, React Native, NativeScript, PhoneGap and so on.
  • Flutter in particular, has managed to successfully grab the attention of the development community by allowing an expressive style that makes it a joy building UIs for mobile apps.
  • It incorporates certain concepts familiar to modern development experience like reactive programming and widget composition, using the Dart platform as its main base of operations.
  • Dart is an object-oriented programming language by Google, which aims to help the developer build modern web applications.
  • This demonstrates the blueprint for an Order with properties and methods.
  • Learning these Dart concepts will take you far once you start building your Flutter applications, so it doesn’t come to you as a surprise.

save | comments | report | share on


Using cancellation tokens on ASP.NET Core MVC actions

  • When the client cancels a request, this token will be signaled and our methods are notified and can act accordingly.
  • A case in which it is signaled - when the client cancels the request.
  • In the demo code I'm just invoking an external endpoint that will take 5 seconds to complete, passing the token to the GetAsync method.
  • In this case, besides passing the CancellationToken along to other asynchronous methods - in this case a Task.Delay but the result of the cancellation is similar to the HttpClient.GetAsync - I'm checking the token to see if it was signaled for cancellation.
  • So, imagine the Task.Delay method didn't accept a CancellationToken as an argument, on the next loop iteration the code would check for a cancellation request and would throw an exception (in this case an OperationCanceledException).

save | comments | report | share on


mpangburn/FunctionKit

  • As a language with first-class functions, Swift supports the use of functions as values.
  • Instead, we use the Function type to wrap a Swift function and provide it with powerful new functionality—pun intended.
  • FunctionKit embraces and enhances Swift's functional capabilities in a way that fits naturally into the language.
  • Alternatively, use one of the static methods described later in this section to initialize a Function by composing several Swift functions.
  • Currying is useful for partially applying a function, i.e. providing a value for one of its arguments to produce a function that takes one fewer argument.
  • The static get method takes in a KeyPath<Root, Value> and returns a function that extracts the value from the root.
  • The static update method takes in a WritableKeyPath<Root, Value> and returns a setter function that propogates an update to the property of a type to an update to an instance of that type.

save | comments | report | share on


vzhou842/faster.js

  • Code compiled with faster.js may produce incorrect results when run on sparse arrays.
  • Restricted method names are the names of methods that faster.js will attempt to rewrite - see Supported Array methods.
  • Sparse arrays are arrays that contain holes or empty slots.
  • It is generally recommended to avoid using sparse arrays.

save | comments | report | share on


How Simple is too Simple to Test?

  • He actually didn't notice the problem but when I was doing a code review on his new tests, I noticed that array('cat', 'dog') types of inputs were not resulting in exceptions and I thought that was suspicious.
  • To summarize, we needed automated testing combined with code reviews to catch this error.
  • We could probably reduce the potential for the same kind of errors in the future by changing some of the names of the validateXXX methods to "verifyXXX." That would make it clear that validate methods return bool and verify methods throw exceptions if they encounter data they don't like.
  • Your unit testing best practices should include testing any behavior you care about, even for code that might appear to be too simple to contain an error.

save | comments | report | share on