Lab 2 – Coding in DH

A heated debate in the humanities revolves around whether professionals in the field should learn how to code. There are convincing arguments on both sides. Many tools exist to abstract coding and provide similar results with minimal effort. With these tools—not to mention advancements in AI—scholars can create digital humanities projects without any coding knowledge. On the other hand, having a basic understanding of coding offers a powerful skill set to accomplish various tasks. Activities such as data acquisition, data modeling and visualization, hosting, and more are all facilitated through coding. While these tasks are achievable with other tools, the ability to perform them independently provides a solid foundation for creating and collaborating effectively.

As a computer science major, I believe that learning to code should be encouraged, even in fields like the humanities. With so many industries and aspects of the world interconnected through technology, having knowledge in this area allows individuals to complete various tasks more efficiently. While coding may not be integral to every field of study, it is undeniably helpful. Moreover, it opens up better avenues for research and fosters growth in conversations within the field.

Recently, I ventured into web development and gained significant insights into how web pages function, as well as how data is stored and served. With this knowledge, I can now create my own websites without relying on external sources. For example, the code block below demonstrates some JavaScript from one of my personal projects related to class content. The script listens for user input on a specific element, then returns and displays autocomplete suggestions for potential matches.

document.addEventListener('DOMContentLoaded', function () {
    const input = document.getElementById('recipient_name');
    const suggestionsBox = document.getElementById('suggestions');
    input.addEventListener('input', function () {
        const query = input.value.trim();
        if (query.length > 0) {
            fetch(`/profile_suggestions/?query=${encodeURIComponent(query)}`)
                .then(response => response.text())
                .then(data => {
                    suggestionsBox.innerHTML = data;
                    suggestionsBox.style.display = 'block';
                })
                .catch(error => console.error('Error fetching suggestions:', error));
        } else {
            suggestionsBox.innerHTML = '';
            suggestionsBox.style.display = 'none';
        }
    });
    suggestionsBox.addEventListener('click', function (event) {
        const clickedItem = event.target.closest('.suggestion-item');  // Capture parent div if child clicked
        if (clickedItem) {
            const name = clickedItem.getAttribute('data-fullname').trim();
            input.value = name;
            suggestionsBox.innerHTML = '';
            suggestionsBox.style.display = 'none';
        }
    });
    document.addEventListener('click', function (event) {
        if (!suggestionsBox.contains(event.target) && event.target !== input) {
            suggestionsBox.innerHTML = '';
            suggestionsBox.style.display = 'none';
        }
    });
}); 

I believe this quote from Kirschenbaum resonates strongly with my position: “Programming is about choices and constraints, and about how you choose to model some select slice of the world around you in the formal environment of a computer.” The code above, while not particularly groundbreaking, provides functionality and ease of use to the user. This allows them to focus on the site’s content without perceiving it as cluttered or restrictive.

In the context of a digital humanities project, having the ability to implement small functionalities like this enables you to better convey your intended messages to users. By ensuring they can focus on the content, rather than the site’s functionality, you enhance their experience and engagement. Ultimately, this helps you communicate your “slice of the world” more effectively through the digital medium.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

css.php