<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>javascript &#8211; CS@Worcester</title>
	<atom:link href="https://cs.worcester.edu/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>https://cs.worcester.edu</link>
	<description>Worcester State University Computer Science Department</description>
	<lastBuildDate>Thu, 19 Dec 2024 04:59:00 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>
<site xmlns="com-wordpress:feed-additions:1">236835116</site>	<item>
		<title>What is up with Error Codes for HTTP Methods</title>
		<link>https://debugducker.wordpress.com/2024/12/18/what-is-up-with-error-codes-for-http-methods/</link>
		
		<dc:creator><![CDATA[debugducker]]></dc:creator>
		<pubDate>Thu, 19 Dec 2024 04:59:00 +0000</pubDate>
				<category><![CDATA[CS-343]]></category>
		<category><![CDATA[CS@Worcester]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[web-development]]></category>
		<category><![CDATA[Week-15]]></category>
		<guid isPermaLink="false">http://debugducker.wordpress.com/?p=58</guid>

					<description><![CDATA[Hello Debug Ducker here, and I have a question. I am sure you are familiar with a 404 error code, as you may have run into it while surfing the web. 404 Not Found means that the server on the other end couldn’t find what it was looking for, and this is cause the URL […]]]></description>
										<content:encoded><![CDATA[<figure class="wp-block-image size-full"><img data-recalc-dims="1" decoding="async" data-attachment-id="66" data-permalink="https://debugducker.wordpress.com/2024/12/18/what-is-up-with-error-codes-for-http-methods/pexels-photo-4439425/" data-orig-file="https://debugducker.wordpress.com/wp-content/uploads/2024/12/pexels-photo-4439425.jpeg" data-orig-size="1880,1253" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="word error on white surface" data-image-description="" data-image-caption="&lt;p&gt;Photo by Vie Studio on &lt;a href=&quot;https://www.pexels.com/photo/word-error-on-white-surface-4439425/&quot; rel=&quot;nofollow&quot;&gt;Pexels.com&lt;/a&gt;&lt;/p&gt;
" data-medium-file="https://debugducker.wordpress.com/wp-content/uploads/2024/12/pexels-photo-4439425.jpeg?w=300" data-large-file="https://debugducker.wordpress.com/wp-content/uploads/2024/12/pexels-photo-4439425.jpeg?w=1024" src="https://i0.wp.com/debugducker.wordpress.com/wp-content/uploads/2024/12/pexels-photo-4439425.jpeg?w=625&#038;ssl=1" alt="" class="wp-image-66" /><figcaption class="wp-element-caption">Photo by Vie Studio on <a href="https://www.pexels.com/photo/word-error-on-white-surface-4439425/" rel="nofollow">Pexels.com</a></figcaption></figure>
<p>Hello Debug Ducker here, and I have a question. I am sure you are familiar with a 404 error code, as you may have run into it while surfing the web. 404 Not Found means that the server on the other end couldn&#8217;t find what it was looking for, and this is cause the URL is not recognized. This can happen when the webpage is no longer available and you tried connecting to it. 404 is quite the common error, that I believe many have seen at least once but would you be able to tell me what other errors you may have encountered in the web, there is quite a few and some obscures ones you may have never seen. </p>
<p>Perhaps you also wondered why 404 is even an error number, why the number is the way it is, why use those specific numbers. Well you see 4xx is specifically for client errors, which means they are errors on your end and not the server. If a server would to have an error than it would use 5xx instead. For example, there is the 500 error code that is an internal server error which just means something messed up in the server and sent you that as a response.  Basically each response code are in different categories, with the error categories coming entirely from 4xx and 5xx.</p>
<p>Now here are ones you know and some obscure ones</p>
<p>400: Bad Request, as in the server could not process the request, either because of a syntax error such as misspelling something</p>
<p>402: Payment Required, says what is on the tin you need to pay, not often used</p>
<p>409: Conflict, the request conflicts with something within the server </p>
<p>414: The URI too long, the URI is long and the server is not willing to handle it</p>
<p>418: I&#8217;m a teapot&#8230;yeah I don&#8217;t understand this one, and yes this is real</p>
<p>There are many of these errors code for 4xx and I would recommend you check it out  with the link below.</p>
<p>There are also some 500 server errors, that are interesting such as</p>
<p>501: Not Implemented, as in the request has not been implemented, so exactly what it says</p>
<p>503: Service is Unavailable, just means the server are down.</p>
<p>And Many More.</p>
<p>Thre are a fascinating amount of error codes for some interesting stuff and I reccomend you see a bunch in the link below.</p>
<p><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status">https://developer.mozilla.org/en-US/docs/Web/HTTP/Status</a></p>
<p>Anyway have a nice error free day day.</p>
<p>MozDevNet. “HTTP Response Status Codes &#8211; HTTP: MDN.” <em>MDN Web Docs</em>, developer.mozilla.org/en-US/docs/Web/HTTP/Status.</p>
<p>“HTTP Status Codes: All 63 Explained &#8211; Including FAQ &amp; Video.” <em>Umbraco</em>, umbraco.com/knowledge-base/http-status-codes/#http-status-code-categories.</p>

<p class="syndicated-attribution"><em>From the blog <a href="https://debugducker.wordpress.com">CS@Worcester – Debug Duck</a> by <a href="https://cs.worcester.edu/author/0/" title="Read other posts by debugducker">debugducker</a></em> and used with permission of the author. All other rights reserved by the author.</p>]]></content:encoded>
					
		
		<enclosure url="https://0.gravatar.com/avatar/639f65f5724ad5a31220ac9485603b29a6e9312a92a9295c4ad34a8a4058bb4d?s=96&#038;d=identicon&#038;r=G" length="0" type="" />
<enclosure url="https://debugducker.wordpress.com/wp-content/uploads/2024/12/pexels-photo-4439425.jpeg" length="0" type="" />

		<post-id xmlns="com-wordpress:feed-additions:1">27339</post-id>	</item>
		<item>
		<title>Week 9 Blog Post</title>
		<link>https://dcastillo54.wordpress.com/2024/03/17/week-9-blog-post/</link>
		
		<dc:creator><![CDATA[dcastillo360]]></dc:creator>
		<pubDate>Mon, 18 Mar 2024 03:19:39 +0000</pubDate>
				<category><![CDATA[CS-443]]></category>
		<category><![CDATA[cs-wsu]]></category>
		<category><![CDATA[CS@Worcester]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[Week 9]]></category>
		<guid isPermaLink="false">http://dcastillo54.wordpress.com/?p=30</guid>

					<description><![CDATA[Choosing a topic for this week I tried to find something we had recently touched upon. Last week we went over mocking and expanding my knowledge of this topic can benefit me and the class. Searching for articles about mocking I stumbled upon one that shares the negatives of using mocking data. To counter-attack the […]]]></description>
										<content:encoded><![CDATA[<p>Choosing a topic for this week I tried to find something we had recently touched upon. Last week we went over mocking and expanding my knowledge of this topic can benefit me and the class. Searching for articles about mocking I stumbled upon one that shares the negatives of using mocking data. To counter-attack the ideas we learned in class it is always great to know both sides to using a concept.&nbsp;</p>
<p>This article doesn’t fully dispose of mocking but gives ideas when it&#8217;s good to use. It gives a variety of examples including “Isolating the unit under test from other components or dependencies that are not relevant to the test, Speeding up the test execution by avoiding network calls or database queries that can be slow or unreliable, and Controlling the test input and output by creating predictable and consistent data that can be easily verified”. These ideas are then counterposed to the negatives such as “Introducing errors or inconsistencies between the mock data and the real data, which can lead to false positives or false negatives in the test results, Reducing the coverage and confidence of the test, by not testing the actual behavior and logic of the external source or the interaction with it, and Increasing the maintenance and complexity of the test, by requiring extra code and logic to create and manage the mock data”. The flaws of mocking data are mainly it does not use real data making it much more different from the real data creating disparities between the two. These tests ignore scenarios with much more complexity and these error and bugs can go unseen. The author assures the reader to use a data source to improve the tests.</p>
<p>After reading this article it gave me insight into the negatives of using mocking. The week prior activities made the use of mocking reduce time in creating classes but it’s good to know when it should be used and when it shouldn’t. I wish there was a perfect solution for every test but to find bugs in your code you must expand your horizon. Reading this article made me see that a variety of tests testing different things can overall benefit you. You never have to completely ignore a type of test but being able to see the positives and negatives can save you in the long run. Plus it will allow you to have a broader knowledge knowing that this may have flaws but there are things I can add to have a satisfactory end product.       </p>
<figure class="wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler">
<div class="wp-block-embed__wrapper">
<a class="m-story" href="https://medium.com/@queenskisivuli/why-mocking-data-is-a-bad-practice-for-testing-a20d2d7104aa"  data-width="500" data-border="1" data-collapsed="">View at Medium.com</a>
</div><figcaption class="wp-element-caption"><a href="https://medium.com/@queenskisivuli/why-mocking-data-is-a-bad-practice-for-testing-a20d2d7104aa">https://medium.com/@queenskisivuli/why-mocking-data-is-a-bad-practice-for-testing-a20d2d7104aa<br /></a></figcaption></figure>
<figure class="wp-block-embed">
<div class="wp-block-embed__wrapper">
<a class="m-story" href="https://medium.com/@queenskisivuli/why-mocking-data-is-a-bad-practice-for-testing-a20d2d7104aa"  data-width="500" data-border="1" data-collapsed="">View at Medium.com</a>
</div>
</figure>
<figure class="wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler">
<div class="wp-block-embed__wrapper">
<a class="m-story" href="https://medium.com/@queenskisivuli/why-mocking-data-is-a-bad-practice-for-testing-a20d2d7104aa"  data-width="500" data-border="1" data-collapsed="">View at Medium.com</a>
</div>
</figure>

<p class="syndicated-attribution"><em>From the blog <a href="https://dcastillo54.wordpress.com">CS@Worcester – DCO</a> by <a href="https://cs.worcester.edu/author/0/" title="Read other posts by dcastillo360">dcastillo360</a></em> and used with permission of the author. All other rights reserved by the author.</p>]]></content:encoded>
					
		
		<enclosure url="https://0.gravatar.com/avatar/f869f8d5c1aeaf6652e98ec96239a238305c52737f6863605330486941629184?s=96&#038;d=identicon&#038;r=G" length="0" type="" />

		<post-id xmlns="com-wordpress:feed-additions:1">20890</post-id>	</item>
		<item>
		<title>Week 14 – Token #1 – CS343</title>
		<link>https://shrimpfriedthisrice.wordpress.com/2023/12/17/week-14-token-1-cs343/</link>
		
		<dc:creator><![CDATA[tempurashrimple]]></dc:creator>
		<pubDate>Sun, 17 Dec 2023 23:09:00 +0000</pubDate>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[CS-343]]></category>
		<category><![CDATA[CS@Worcester]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[web-development]]></category>
		<category><![CDATA[Week-14]]></category>
		<guid isPermaLink="false">http://shrimpfriedthisrice.wordpress.com/?p=72</guid>

					<description><![CDATA[For this blog I’ll be using one of my tokens for this class so I can hit the 6 blog minimum before the semester is over. In this blog post, I wanted to look more into JavaScript since I didn’t really know too much about it. I struggled with the backend homework we had because […]]]></description>
										<content:encoded><![CDATA[<p>For this blog I&#8217;ll be using one of my tokens for this class so I can hit the 6 blog minimum before the semester is over.</p>
<p>In this blog post, I wanted to look more into JavaScript since I didn&#8217;t really know too much about it. I struggled with the backend homework we had because I never knew anything about the syntax or language at all. So, I want to learn a bit more about this language within this blog. For this, I consulted this website, and gave it a good hearty read:</p>
<p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript" rel="nofollow">https://developer.mozilla.org/en-US/docs/Web/JavaScript</a></p>
<p>This site gives an overview of JavaScript and the applications in which it is used in general, and what benefits and downsides it has compared to other languages.</p>
<p>What I found very interesting is that I originally knew that JavaScript was mainly used for website development and coding, but this site gave some examples of applications such as Node.js and Adobe Acrobat. I believe we&#8217;ve actually utilized Node.js before in our classes, but I can&#8217;t quite put my finger on what exactly we used it for, but I recgonize the name appearing in one or more of the repositories we&#8217;ve been working with.</p>
<p>It seems like JavaScript is much like Java in the sense that it can use object oriented code, but I think the similarities between the two end there. In the past, I always heard that JavaScript was a completely different beast from Java, and after look more into it, I see why. This site below describes the differences:</p>
<p><a href="https://www.lighthouselabs.ca/en/blog/java-vs-javascript" rel="nofollow">https://www.lighthouselabs.ca/en/blog/java-vs-javascript</a></p>
<p>JavaScript it object-orientedcode, whereas Java is object-based. That may sound the same as each other, but there is some very specific distinctions between them. Java relies on objects to function, whereas JavaScript has functionality for objects and suggests use of them with it&#8217;s language, it is not required. JavaScript is also a lot more fluid with it&#8217;s syntax, and has a lot more free-form and flexibility with it, which reminds me a lot of what I&#8217;ve heard about Python. Java is a lot more rigid, and requires specific pre-set uses of it&#8217;s syntax.</p>
<p>But back to JavaScript, it seems like its The language for web design, as a lot of it&#8217;s language is made with web design in mind. My future for this area of study is some form of design in technilogical areas, so it would be possible I go into Web Design. If I do, I&#8217;ll definitely have to teach myself more JavaScript. It seems like a really useful language to have on hand in that case.</p>
<p>I will be posting one other blog today, using another token, so stay tuned for another!</p>

<p class="syndicated-attribution"><em>From the blog <a href="https://shrimpfriedthisrice.wordpress.com">CS@Worcester – You&amp;#039;re Telling Me A Shrimp Wrote This Code?!</a> by <a href="https://cs.worcester.edu/author/0/" title="Read other posts by tempurashrimple">tempurashrimple</a></em> and used with permission of the author. All other rights reserved by the author.</p>]]></content:encoded>
					
		
		<enclosure url="https://1.gravatar.com/avatar/d32aac6a6c8a8da64a549030aea18c3c1fd2d366336d55ef20d2a1a8875ea2ff?s=96&#038;d=identicon&#038;r=G" length="0" type="" />

		<post-id xmlns="com-wordpress:feed-additions:1">20288</post-id>	</item>
		<item>
		<title>JavaScript</title>
		<link>https://blog221237013.wordpress.com/2021/12/05/cs-343-6/</link>
		
		<dc:creator><![CDATA[gkitenge]]></dc:creator>
		<pubDate>Mon, 06 Dec 2021 04:43:57 +0000</pubDate>
				<category><![CDATA[CS-343]]></category>
		<category><![CDATA[CS@Worcester]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Week 12]]></category>
		<guid isPermaLink="false">http://blog221237013.wordpress.com/?p=141</guid>

					<description><![CDATA[JavaScript is a scripting language for creating dynamic web page content. It creates elements for improving site visitors’ interaction with web pages, such as dropdown menus, animated graphics, and dynamic background colors. Developers generally use JavaScript alongside HTML and CSS to create a dynamic website. The scripting language works well with CSS in formatting HTML elements. However,<a class="more-link" href="https://blog221237013.wordpress.com/2021/12/05/cs-343-6/">Continue reading <span class="screen-reader-text">"JavaScript"</span></a>]]></description>
										<content:encoded><![CDATA[<p>JavaScript is a scripting language for creating dynamic web page content. It creates elements for improving site visitors’ interaction with web pages, such as dropdown menus, animated graphics, and dynamic background colors. Developers generally use JavaScript alongside&nbsp;HTML and&nbsp;CSS to create a dynamic website. The scripting language works well with CSS in formatting HTML elements. However, it still maintains user interaction, something that CSS cannot do by itself.</p>
<p>JavaScript’s implementations within the web, mobile application, and game development make the scripting language worth learning. You can do so via learning platforms like BiteDegree or by exploring free JavaScript templates and applications on code hosting platforms like GitHub. &nbsp;</p>
<p><strong>What is the use of JavaScript?</strong></p>
<p>JavaScript has continued to grow alongside new browsers like&nbsp;Mozilla Firefox&nbsp;and&nbsp;Google Chrome&nbsp;since then. The latter even started developing the first modern JavaScript engine, called&nbsp;V8, which compiles bytecode into native machine code. Today, JavaScript has plenty of frameworks and libraries to simplify complex projects, such as AngularJS, jQuery, and ReactJS. While it caters to web-based programs the most, JavaScript programming features have other implementations in different areas. The following are several basic uses of JavaScript.</p>
<p>The development of JavaScript frameworks, consisting of JavaScript code libraries, allows developers to use pre-written JavaScript code in their projects. It saves them time and effort from having to code programming features from scratch. Each JavaScript framework has features that aim to simplify the development and debugging process.</p>
<p>For example, front-end JavaScript frameworks like jQuery and ReactJS improve design efficiency. They allow developers to reuse and update code components without affecting each other, function or value-wise. The implementation of JavaScript code in Node.js also plays an important role in web development. Node.js can reduce server response time due to its single-threaded nature and non-blocking architecture and omit delays.  </p>
<p>One of JavaScript’s core functions is adding dynamicity to web pages. This includes displaying animations, modifying text visibility, and creating dropdown menus. </p>
<p>While you can use only HTML and CSS code to build a website, it will only have a static display. With JavaScript, a user can interact with web pages and have a better browsing experience.</p>
<p>Additionally, JavaScript lets you change HTML content and attribute values without reloading the web page first. This is because JavaScript supports the following data types:</p>
<ul>
<li><strong>String</strong> ‒ consists of textual data written inside quotes. For example, <strong>“Hello world”</strong>, <strong>‘Hello world’</strong>, and <strong>“Display ‘Hello world’ text”</strong>.</li>
<li><strong>Number</strong> ‒ covers integer and floating-point numbers between (2^53 – 1) and -(2^53 – 1).</li>
<li><strong>Boolean</strong> ‒ a logical data type with <strong>true</strong> and <strong>false</strong> values.</li>
<li><strong>BigInt</strong> ‒ represents integer data of arbitrary length.</li>
<li><strong>Null</strong> ‒ contains a null value.</li>
<li><strong>Undefined</strong> ‒ includes declared but not assigned variables.</li>
<li><strong>Symbol</strong> ‒ provides unique identifiers for objects.</li>
<li><strong>Object</strong> ‒ for complex data structures written with curly braces. For example, <strong>{item:”Book”, information:”biography”}</strong>.</li>
</ul>
<p>I chose to talk about JavaScript because it&#8217;s one of the most fundamental in programming and as computer science, I am supposed to know about JavaScript because it&#8217;s mostly used and also very important. </p>
<p><a href="https://www.hackreactor.com/blog/what-is-javascript-used-for">What is JavaScript used for? | Hack Reactor</a></p>
<p><a href="https://www.hostinger.com/tutorials/what-is-javascript">What Is JavaScript? A Basic Introduction to JS for Beginners (hostinger.com)</a></p></p>

<p class="syndicated-attribution"><em>From the blog <a href="https://blog221237013.wordpress.com">CS@Worcester – Gracia&amp;#039;s Blog (Computer Science Major)</a> by <a href="https://cs.worcester.edu/author/0/" title="Read other posts by gkitenge">gkitenge</a></em> and used with permission of the author. All other rights reserved by the author.</p>]]></content:encoded>
					
		
		<enclosure url="https://2.gravatar.com/avatar/ecd02ac9645f9a8430249106ef082a4d?s=96&#038;d=identicon&#038;r=G" length="0" type="" />

		<post-id xmlns="com-wordpress:feed-additions:1">16082</post-id>	</item>
		<item>
		<title>Jump to Jasmine Specs with Rinari</title>
		<link>http://dthompson.us/jump-to-jasmine-specs-with-rinari.html</link>
		
		<dc:creator><![CDATA[David Thompson]]></dc:creator>
		<pubDate>Tue, 17 Dec 2013 18:00:00 +0000</pubDate>
				<category><![CDATA[emacs]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[WSU]]></category>
		<guid isPermaLink="false">http://cs.worcester.edu/blog/?guid=35fa769e43255a0476a49e1438a19b58</guid>

					<description><![CDATA[<p>I use the <a href="https://github.com/eschulte/rinari">rinari</a> Emacs mode to assist me when working on rails
projects.  One of rinari's most useful features is the ability to
quickly jump from one file to another related file.  I use this
feature almost exclusively for jumping between a ruby class file and
its associated rspec file, but lately I've been spending most of my
time writing javascript.  At VHL, we use <a href="http://pivotal.github.io/jasmine/">jasmine</a> for our unit testing
framework and the <a href="https://github.com/pivotal/jasmine-gem">jasmine ruby gem</a> to integrate it with our rails
projects.  Rinari doesn't have any built-in jump settings for jasmine
test files, so I wrote this quick hack to make it work:</p>
<div><pre><span>;; Make rinari jump to/from javascript source files and specs.</span>
<span>(</span><span>setcdr</span> <span>(</span><span>assoc</span> <span>'javascript</span> <span>rinari-jump-schema</span><span>)</span>
        <span>'</span><span>(</span><span>"j"</span>
          <span>((</span><span>"app/assets/javascripts/\\1.js"</span> <span>.</span> <span>"spec/javascripts/\\1_spec.js"</span><span>)</span>
           <span>(</span><span>"spec/javascripts/\\1_spec.js"</span>  <span>.</span> <span>"app/assets/javascripts/\\1.js"</span><span>)</span>
           <span>(</span><span>t</span> <span>.</span> <span>"spec/javascripts/.*"</span><span>)</span>
           <span>(</span><span>t</span> <span>.</span> <span>"app/javascripts/.*"</span><span>))</span>
          <span>t</span><span>))</span>
<span>(</span><span>rinari-apply-jump-schema</span> <span>rinari-jump-schema</span><span>)</span>
</pre></div>
<p>Now I can press <tt><span>C-c</span> ; f j</tt> to jump between a javascript file in
<tt>app/assets/javascripts/</tt> and its jasmine test file in
<tt>spec/javascripts/</tt>.  Perhaps I shouldn't be overwriting the
predefined (but not very useful) javascript jump settings, but I
really wanted to use the <tt>j</tt> key.</p>]]></description>
										<content:encoded><![CDATA[<p>I use the <a class="reference external" href="https://github.com/eschulte/rinari">rinari</a> Emacs mode to assist me when working on rails<br />
projects.  One of rinari&#8217;s most useful features is the ability to<br />
quickly jump from one file to another related file.  I use this<br />
feature almost exclusively for jumping between a ruby class file and<br />
its associated rspec file, but lately I&#8217;ve been spending most of my<br />
time writing javascript.  At VHL, we use <a class="reference external" href="http://pivotal.github.io/jasmine/">jasmine</a> for our unit testing<br />
framework and the <a class="reference external" href="https://github.com/pivotal/jasmine-gem">jasmine ruby gem</a> to integrate it with our rails<br />
projects.  Rinari doesn&#8217;t have any built-in jump settings for jasmine<br />
test files, so I wrote this quick hack to make it work:</p>
<div class="highlight">
<pre><span class="c1">;; Make rinari jump to/from javascript source files and specs.</span>
<span class="p">(</span><span class="nv">setcdr</span> <span class="p">(</span><span class="nb">assoc</span> <span class="ss">&#39;javascript</span> <span class="nv">rinari-jump-schema</span><span class="p">)</span>
        <span class="o">&#39;</span><span class="p">(</span><span class="s">&quot;j&quot;</span>
          <span class="p">((</span><span class="s">&quot;app/assets/javascripts/\\1.js&quot;</span> <span class="o">.</span> <span class="s">&quot;spec/javascripts/\\1_spec.js&quot;</span><span class="p">)</span>
           <span class="p">(</span><span class="s">&quot;spec/javascripts/\\1_spec.js&quot;</span>  <span class="o">.</span> <span class="s">&quot;app/assets/javascripts/\\1.js&quot;</span><span class="p">)</span>
           <span class="p">(</span><span class="no">t</span> <span class="o">.</span> <span class="s">&quot;spec/javascripts/.*&quot;</span><span class="p">)</span>
           <span class="p">(</span><span class="no">t</span> <span class="o">.</span> <span class="s">&quot;app/javascripts/.*&quot;</span><span class="p">))</span>
          <span class="no">t</span><span class="p">))</span>
<span class="p">(</span><span class="nv">rinari-apply-jump-schema</span> <span class="nv">rinari-jump-schema</span><span class="p">)</span>
</pre>
</div>
<p>Now I can press <tt class="docutils literal"><span class="pre">C-c</span> ; f j</tt> to jump between a javascript file in<br />
<tt class="docutils literal">app/assets/javascripts/</tt> and its jasmine test file in<br />
<tt class="docutils literal">spec/javascripts/</tt>.  Perhaps I shouldn&#8217;t be overwriting the<br />
predefined (but not very useful) javascript jump settings, but I<br />
really wanted to use the <tt class="docutils literal">j</tt> key.</p>

<p class="syndicated-attribution"><em>From the blog <a href="http://dthompson.us/">dthompson</a> by <a href="https://cs.worcester.edu/author/0/" title="Read other posts by David Thompson">David Thompson</a></em> and used with permission of the author. All other rights reserved by the author.</p>]]></content:encoded>
					
		
		<enclosure url="" length="0" type="" />

		<post-id xmlns="com-wordpress:feed-additions:1">2770</post-id>	</item>
		<item>
		<title>AngularJS Post-mortem</title>
		<link>http://dthompson.us/angularjs-post-mortem.html</link>
		
		<dc:creator><![CDATA[David Thompson]]></dc:creator>
		<pubDate>Thu, 08 Aug 2013 15:00:00 +0000</pubDate>
				<category><![CDATA[angularjs]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[WSU]]></category>
		<guid isPermaLink="false">http://cs.worcester.edu/blog/?guid=d33b194f78b4eaa078754df7cd8b4bef</guid>

					<description><![CDATA[AngularJS is the new popular client-side Javascript application
framework developed by Google. We have recently adopted it at Vista
Higher Learning for building our latest features that require a lot
client-side logic. Now that I have a few application...]]></description>
										<content:encoded><![CDATA[<p><a class="reference external" href="http://angularjs.org/">AngularJS</a> is the new popular client-side Javascript application<br />
framework developed by Google. We have recently adopted it at Vista<br />
Higher Learning for building our latest features that require a lot<br />
client-side logic. Now that I have a few applications under my belt,<br />
it&#8217;s time to talk about my experience.</p>
<p>If you want a quick TL;DR: I think AngularJS is good, but it has a<br />
steep learning curve and there&#8217;s no well defined set of best<br />
practices.</p>
<p>Note: I will be using plenty of terms that will probably only make<br />
sense for people that have used AngularJS.</p>
<div class="section" id="the-good-stuff">
<h2>The Good Stuff</h2>
<p>These are the things that went well. The things that made me glad that<br />
we chose to use AngularJS.</p>
<div class="section" id="easier-testing">
<h3>Easier Testing</h3>
<p>Our Javascript test suite uses <a class="reference external" href="http://pivotal.github.io/jasmine/">Jasmine</a>. AngularJS is built with test<br />
frameworks like Jasmine in mind. AngularJS could tends to be easily<br />
testable due to dependency injection. When the components of an<br />
application don&#8217;t rely on global state, it is easier to mock services<br />
for unit tests.</p>
</div>
<div class="section" id="separation-of-concerns">
<h3>Separation of Concerns</h3>
<p>AngularJS stresses separating the view from the data structures and<br />
logic behind it. I think everyone that&#8217;s written a somewhat complex<br />
JQuery application can relate to the mess of CSS selectors and click<br />
callbacks that the code quickly degenerates into.</p>
<p>AngularJS allows you to break up the DOM into logical chunks that are<br />
handled by separate controllers. Treating the application as many<br />
small pieces working together rather than one giant DOM blob keeps the<br />
code clean. Message passing via <cite>$emit</cite> and <cite>$broadcast</cite> keeps<br />
controllers loosely coupled to each other.</p>
</div>
<div class="section" id="no-more-jquery-spaghetti">
<h3>No More JQuery Spaghetti</h3>
<p>Directives, the strategy for encapsulating DOM manipulation, are<br />
wonderful. It is an elegant solution to the mess that was JQuery<br />
selectors and event callbacks. AngularJS comes with a lot of<br />
directives out of the box to handle the most common stuff like<br />
showing/hiding elements, handling clicks, dynamically setting CSS<br />
classes.</p>
</div>
<div class="section" id="more-maintainable-code">
<h3>More Maintainable Code</h3>
<p>AngularJS is feature-rich. It does a lot on your behalf, which greatly<br />
reduces the amount of boilerplate code needed to get a prototype up<br />
and running. I had the opportunity to essentially rewrite an existing<br />
JQuery application using AngularJS. The results were clear: The<br />
AngularJS version had fewer lines of code, was more readable, and<br />
was easier to debug.</p>
</div>
</div>
<div class="section" id="bumps-in-the-road">
<h2>Bumps in the Road</h2>
<p>These are the things that didn&#8217;t go smoothly. They boil down to<br />
AngularJS having a steep learning curve and ill-informed software<br />
design decisions on my part.</p>
<div class="section" id="understanding-the-magic">
<h3>Understanding the Magic</h3>
<p>A lot of things seem to happen by magic. For example, it is possible<br />
to make a asynchronous request and get a promise object in<br />
return. When the promise is assigned to a variable on <cite>$scope</cite>,<br />
AngularJS not only knows to ignore it while the request hasn&#8217;t<br />
finished, but it will re-assign to that variable the value of the<br />
asynchronous call when it completes. It is a nice feature, but it<br />
takes some digging to find out what is really going on.</p>
</div>
<div class="section" id="poor-documentation">
<h3>Poor Documentation</h3>
<p>I know I&#8217;m not the only one that hates the official AngularJS<br />
documentation. The documentation is getting more complete, but it&#8217;s<br />
still not very useful. Functions frequently have a blurb describing<br />
what they do, but no explanation of the parameter list. It&#8217;s hard to<br />
use a function that doesn&#8217;t describe what it expects for input.</p>
<p>When the documentation confused us, which it did frequently, we turned<br />
to the AngularJS book from <a class="reference external" href="http://shop.oreilly.com/product/0636920028055.do">O&#8217;Reilly</a> for help. I need to get around<br />
to reading more of it.</p>
</div>
<div class="section" id="restful-resources-and-rails">
<h3>RESTful Resources and Rails</h3>
<p>AngularJS claims to be targeted at CRUD applications, but using the<br />
HTTP backend and the <cite>Resource</cite> abstraction that sits on top of it was<br />
particularly difficult. A good amount of time was spent on trying to<br />
get the HTTP requests from resources to conform to what our Rails<br />
backend expects, like root-wrapping.</p>
</div>
<div class="section" id="bloated-controllers">
<h3>Bloated Controllers</h3>
<p>I frequently made controllers that had too much state and logic that<br />
should have been extracted into services/factories/etc. A controller<br />
would start out slim but would quickly grow to several hundred lines<br />
of code as features were added. Controllers should be the middle man<br />
between the view and the model and that&#8217;s it.</p>
<p>Some tell-tale signs that a controller is becoming bloated:</p>
<ul class="simple">
<li>There are a lot of private functions (not defined on <cite>$scope</cite>)</li>
<li>Functions are defined on <cite>$scope</cite> just so you can unit-test them,<br />
but are never used in the template</li>
</ul>
<p>I attribute controller bloat to a lack of knowing the appropriate uses<br />
for other AngularJS components. It was easy to just keep adding to the<br />
controller.</p>
</div>
</div>
<div class="section" id="conclusion">
<h2>Conclusion</h2>
<p>Overall, I think things went well, but I (and the rest of my team)<br />
made a lot of beginner mistakes. But that&#8217;s the learning process,<br />
isn&#8217;t it?</p>
<p>Now that I know more about AngularJS, it will be easier to make better<br />
design decisions moving forward.</p>
<p>I believe that as AngularJS continues to mature, some concensus in the<br />
community about best practices will emerge that will make things<br />
easier for beginners.</p>
</div>

<p class="syndicated-attribution"><em>From the blog <a href="http://dthompson.us/">dthompson</a> by <a href="https://cs.worcester.edu/author/0/" title="Read other posts by David Thompson">David Thompson</a></em> and used with permission of the author. All other rights reserved by the author.</p>]]></content:encoded>
					
		
		<enclosure url="" length="0" type="" />

		<post-id xmlns="com-wordpress:feed-additions:1">2690</post-id>	</item>
	</channel>
</rss>
