DPS907 notes – Thu Oct 8

Keys to success in this course. More on link relations.

.

Review Test 3

Test 3 will be returned and discussed. The goal is to help you improve your answer quality.

Example answers will be posted after each test. On the class notes page, click any of the test links, to view the answer page.

.

Test 4 is today

Next, Test 4 will be written.

.

Advice about success in this course

We have completed about one-third of the course. We hope that you’ve enjoyed it so far.

While checking and marking your work, your professor has noticed some good work, but also some indicators of poor scholarship among the work that has earned low grades. This section of the notes has advice on how to improve.

The following advice is for every student in the course. It will also work for other courses in our software development programs. Here’s the advice:

Prepare

Prepare before every class. Your professor expects you to have read and studied the notes, including the linked and recommended readings. You must perform some learning activities before class. You don’t need your professor to verbally dictate content that you can consume better and more efficiently on your own. Therefore, make it a habit to prepare before class.

Readings are important. It is impossible to learn what you need to learn in this course, by simply listening to your professor talk for ninety minutes each week. It is also impossible to learn what you need to learn simply by writing code, and ignoring all of the good advice and best practices that are communicated to you through the readings.

The way you work through the content is important. Don’t just move your eyes over the content, with the support of a partially-engaged and distracted brain. Instead, read critically, concentrate, and think as you read. Look up words or terms that are unfamiliar. Open and study the code examples (using Visual Studio), while you are working through the content. Follow the links to the linked material, and work through that too. Write down questions that you need answers to (and follow up by asking your professor or someone else in your support-and-learning network).

Review

Review the course content. Every week. How?

Schedule a regular time to do this work. You have an appointment calendar on your computer or phone – use it. When? Whatever works for your schedule, but it may be useful to do this activity on Monday or Tuesday or Wednesday, because you will recall techniques and best practices that will be useful as you work on that week’s assignment (lab). Also, it will help you “study” for the regular Thursday test.

Review the material in sequence. Two sequences could work: New-to-old, or old-to-new. In other words, you could start with the most recent material, and work backwards, day by day, to the oldest material. Alternatively, you could start with the oldest material, and work forwards to the current material.

Is there a benefit to a regular review? Yes. Ask yourself a question, and answer it honestly: Have you ever read something technical for a second (or third) time, and “discovered” the real meaning of something that you know you have read before? The answer will always be “yes”. It’s natural, and it’s part of being human.

Some students establish a “study group” with a few classmates. That’s a good practice. Quiz each other. Have each member be responsible for digging deep into a specific topic, and reporting the results to the others.

Resources

Use the recommended resources. There’s “gold” in the resources. Don’t ignore the resources that you think are too dense, or technical, or boring. Read them. Re-read them. If you begin to read content that’s unfamiliar, or beyond your current level of knowledge or understanding, you should still skim/read it. That way, when you later raise your level of knowledge and understanding, you will remember the material, and can handle it.

Assignments

When working on the programming assignments…

Follow instructions.

Make a “coding plan” before you begin writing code. Whatever form works for you, use it. (Flowchart, pseudocode, English-like statements, boxes-and-arrows – whatever.)

Do not copy-paste code, hoping that it will work. Write your code without using copy-paste. Later, when you realize that you are writing and repeating the same code as before, then you can consider using copy-paste. And, you should look for opportunities to refactor your code.

Tests

When working on the weekly tests…

Understanding a test question is important. Make sure you are answering the question, and not some other question. Ask your professor – during the test – if you’re unsure. (For best results, come up to the front to ask your question. That way, you’ll have some privacy.)

Understanding the question format is important too. Our questions are conversational in nature. They skew towards applying the knowledge you’re learning. They’re never trivial. The overall goal is to help you become a better explainer, in writing, and verbally. That will pay off in future work/career opportunities.

.

New feature in the code examples

Your professor has added “comment tokens” to the LinkRelationsMore code example. The plan is to continue doing this in future code examples.

As you will learn in the linked article, Visual Studio has a built-in token named “TODO”. In your Visual Studio, you will add a custom token named “ATTENTION”.

Open Tools > Options. Navigate to the Environment > Task List panel. Enter “ATTENTION” into the “Name:” textbox, and click the “Add” button. It will add it to the “Token list:”.

attention-token-tools-options

.

Then, when you show your Task Tist (from the View menu), it will show you a nice list of tokenized comments:

attention-token-task-list

.

Each item on the list can be double-clicked. When you do that, the source code file will open, and it will scroll to the position of the comment. Enjoy.

.

Link relations and associated objects

As you learned above, a new code example, named LinkRelationsMore, has been posted.

It builds upon the “intro” code example, by working with both Manufacturer and Vehicle entities. Obviously, there’s an association between the two.

How does it affect the link relations implementation? Very little.

The principle remains the same: Deliver an item, or a collection, with link relations data.

However, do not do this for nested (contained) objects or collections. (Just deliver the “base”.)

Study the code to learn the similarities and differences. Run it, and use Fiddler to work with the app.

.

Deliver a template for an “add new” request

Here’s a scenario: A user of your web service wants to add a new Vehicle object. What properties must be provided? Which data types are used? Are there any other constraints?

One popular solution is to deliver a template with the response to the ‘get-all’ request. That’s the most natural place for it, because we’re already delivering a link relation for the collection.

How do we implement this? Two tasks:

  1. Add a resource model class for the template
  2. Add a property to the ‘get-all’ link relations container class for a template object

.

Add a resource model class…

Add a resource model class for the template. In the code example, it is named “VehicleAddTemplate”.

It has string properties. The property names match – exactly – the names of the properties in the “VehicleAdd” resource model class.

All properties have getters only. No setters. When initialized, the class object has all it needs to ‘tell a story’ to the user.

The property values will tell the user about the data they must send, including data types and other constraints (length, range, etc.).

.

Add a property…

Add a property to the ‘get-all’ link relations container class. Add code in the constructor to initialize the property’s value.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

%d bloggers like this: