Credits: Theta Trainings ๐โญ๐
Follow Bishir Tijjani ๐๐บ for the most amazing content related to JavaScript, programming, ReactJS & Web Development
Follow Bishir Tijjani ๐๐บ for the most amazing content related to JavaScript, programming, ReactJS & Web Development
Make fields '๐ฟ๐ฒ๐ฎ๐ฑ๐ผ๐ป๐น๐' when exclusively assigned in the constructor!
A field set only in a constructor without the readonly modifier may lead to ambiguity in its intended use.
Marking such fields as readonly enhances clarity about their purpose.
The readonly modifier prevents unintentional alterations by future maintainers.
However, there are some ๐ฒ๐ ๐ฐ๐ฒ๐ฝ๐๐ถ๐ผ๐ป๐:
โ Fields declared in classes marked with the Serializable attribute.
โ Fields declared in partial classes.
โ Fields with attributes are ignored.
โ Fields of type struct that are not primitive or pointer types are also ignored because of possible unwanted behavior.
A field set only in a constructor without the readonly modifier may lead to ambiguity in its intended use.
Marking such fields as readonly enhances clarity about their purpose.
The readonly modifier prevents unintentional alterations by future maintainers.
However, there are some ๐ฒ๐ ๐ฐ๐ฒ๐ฝ๐๐ถ๐ผ๐ป๐:
โ Fields declared in classes marked with the Serializable attribute.
โ Fields declared in partial classes.
โ Fields with attributes are ignored.
โ Fields of type struct that are not primitive or pointer types are also ignored because of possible unwanted behavior.
๐๐๐ฎ๐ฟ๐ฑ is a conditional statement to perform early input validation and detect problematic states, mitigating potential execution errors within a method.
The ๐ด๐๐ฎ๐ฟ๐ฑ ๐ฐ๐น๐ฎ๐๐๐ฒ runs before the main code, quickly checking if specific conditions are not met and ๐ณ๐ฎ๐ถ๐น๐ถ๐ป๐ด ๐ณ๐ฎ๐๐ if necessary. It guards the rest of the code.
โ By checking for invalid input or problematic states at the beginning code becomes less cluttered and easier to follow, enhancing both code ๐ฟ๐ฒ๐ฎ๐ฑ๐ฎ๐ฏ๐ถ๐น๐ถ๐๐ and ๐บ๐ฎ๐ถ๐ป๐๐ฎ๐ถ๐ป๐ฎ๐ฏ๐ถ๐น๐ถ๐๐.
โ This technique is highly effective for preventing deep conditional nesting, making the logic flow clearer and more transparent.
Do you use ๐๐๐ฎ๐ฟ๐ฑ๐ & ๐๐ฎ๐ถ๐น ๐๐ฎ๐๐ techniques in your code? ๐
๐ If this is useful, ๐ง๐๐ฅ๐ค๐จ๐ฉ to spread the knowledge.
๐ Follow Poorna Soysa and click the notification bell๐on his likedin profile to receive notifications for all his upcoming posts.
The ๐ด๐๐ฎ๐ฟ๐ฑ ๐ฐ๐น๐ฎ๐๐๐ฒ runs before the main code, quickly checking if specific conditions are not met and ๐ณ๐ฎ๐ถ๐น๐ถ๐ป๐ด ๐ณ๐ฎ๐๐ if necessary. It guards the rest of the code.
โ By checking for invalid input or problematic states at the beginning code becomes less cluttered and easier to follow, enhancing both code ๐ฟ๐ฒ๐ฎ๐ฑ๐ฎ๐ฏ๐ถ๐น๐ถ๐๐ and ๐บ๐ฎ๐ถ๐ป๐๐ฎ๐ถ๐ป๐ฎ๐ฏ๐ถ๐น๐ถ๐๐.
โ This technique is highly effective for preventing deep conditional nesting, making the logic flow clearer and more transparent.
Do you use ๐๐๐ฎ๐ฟ๐ฑ๐ & ๐๐ฎ๐ถ๐น ๐๐ฎ๐๐ techniques in your code? ๐
๐ If this is useful, ๐ง๐๐ฅ๐ค๐จ๐ฉ to spread the knowledge.
๐ Follow Poorna Soysa and click the notification bell๐on his likedin profile to receive notifications for all his upcoming posts.
๐ In LINQ queries, the order in which you apply operations can affect performance. If you filter a collection using ๐ช๐ต๐ฒ๐ฟ๐ฒ before sorting it with ๐ข๐ฟ๐ฑ๐ฒ๐ฟ๐๐, you reduce the number of items that need to be sorted. Sorting is generally more computationally expensive than filtering, so this can result in significant performance benefits, especially for larger collections.
๐ฅ This approach enhances performance because we're sorting a smaller subset of the original data.
๐ฅ This approach enhances performance because we're sorting a smaller subset of the original data.
Here is first a jQuery AJAX example showing how to make an AJAX call in jQuery:
var jqxhr =
$.ajax({
type: "POST",
url: "/theServiceToCall.html",
data: {
name : "The name",
desc : "The description"
}
})
.done (function(response, textStatus, jqXHR) { alert("Success: " + response); })
.fail (function(jqXHR, textStatus, errorThrown) { alert("Error"); })
.always(function(jqXHROrData, textStatus, jqXHROrErrorThrown) { alert("complete"); })
;