Taken from a PeopleCode app package to be used as a refactoring exercise

Overview

The code below was taken from a PeopleCode app package to be used as a refactoring exercise.

Packages

  • original: contains the code below translated into Kotlin
  • v1: refactored without changing the signature of the method
  • v2: refactored to use functional interfaces (SAM interfaces)
  • v3: refactored using function types
method CanAddPath
   /+ &psUserId as String, +/
   /+ &psAcadCareer as String, +/
   /+ &psPathType as String +/
   /+ Returns Boolean +/
   try
      
      Local HPT_DP_APP_SETTINGS:AppCareerSettings &oCareerSettings = &moContainer.AppSettings.GetCareerSettings(&psAcadCareer);
      
   catch HPT_DP_APP_SETTINGS:EXCEPTIONS:CareerNotFound &ex
      Return False;
   end-try;
   
   Local integer &iMaxCount;
   
   If Not &moContainer.IsStaffRequest Then
      &iMaxCount = &oCareerSettings.MaxPathsCount;
   Else
      &iMaxCount = &oCareerSettings.MaxAdvisorPathsCount;
   End-If;
   
   If &psPathType = &moPathTypes.WhatIf Then
      
      If Not &moContainer.IsStaffRequest Then
         &iMaxCount = &oCareerSettings.MaxWhatIfPathsCount;
      Else
         Return True;
      End-If;
      
   End-If;
   
   If &iMaxCount = 0 Then
      Return False;
   End-If;
   
   Local integer &iCount;
   Local string &sSQL;
   
   &sSQL = "        select count(*)          ";
   &sSQL = &sSQL | "  from %Table(:1)        ";
   &sSQL = &sSQL | " where EMPLID       = :2 ";
   &sSQL = &sSQL | "   and INSTITUTION  = :3 ";
   &sSQL = &sSQL | "   and ACAD_CAREER  = :4 ";
   &sSQL = &sSQL | "   and OWNER_ID     = :5 ";
   &sSQL = &sSQL | "   and H_DP_SP_TYPE = :6 ";
   
   SQLExec(&sSQL, Record.H_DP_SP_PATH, &msEmplId, &msInstitution, &psAcadCareer, &psUserId, &psPathType, &iCount);
   
   Return (&iCount < &iMaxCount);
   
end-method;
You might also like...
MVI Architecture Android Beginners: Sample App

MVI Architecture Android Beginners: Sample App This repository contains a sample app that implements MVI architecture using Kotlin, ViewModel, LiveDat

Event Trackr Android app. Allows users to track birthdays and anniversaries of friends and family.
Event Trackr Android app. Allows users to track birthdays and anniversaries of friends and family.

Trackr Event Trackr Android app. Allows users to track birthdays and anniversaries of friends and family. You need to open this project in Android Stu

A sample app that demonstrate how to build an Android application using the Uncle Bob's Clean Architecture approach
A sample app that demonstrate how to build an Android application using the Uncle Bob's Clean Architecture approach

A sample app that demonstrate how to build an Android application using the Uncle Bob's Clean Architecture approach

A sample photo browsing app in Kotlin, Android using Picsum image API.
A sample photo browsing app in Kotlin, Android using Picsum image API.

Picsum Photo App Functionality The app's functionality includes: Fetch a list of images from picsum photos api (https://picsum.photos/) and show them

Base App - MVVM, Base Structure, Hilt, Kotlin Flow, Retrofit
Base App - MVVM, Base Structure, Hilt, Kotlin Flow, Retrofit

Base App - MVVM, Base Structure, Hilt, Kotlin Flow, Retrofit

A sample Album list app that shows how to use ViewModels and Room together with RxJava & Dagger2, in Kotlin by Clean Architecture.

Kotlin-MVVM-Hilt A sample Album list app that shows how to use ViewModels and Room together with RxJava & Dagger2, in Kotlin by Clean Architecture. Im

Reach plc. Apps Team Exercise (Junior)Reach plc. Apps Team Exercise (Junior)

Reach plc. Apps Team Exercise (Junior) Description One of our magazines is looking for new sources of revenues and starts a few partnerships with beau

A repo to work to the best known refactoring practices provided in Martin Fowler's book

refactoring_playground A repo to work to the most known refactoring practices provided in Martin Fowler's book Extract function Inline function Extrac

A demo app to show how to detect screenshots taken by the user while using the app
A demo app to show how to detect screenshots taken by the user while using the app

Screenshot Detector A demo app to show how to detect screenshots taken by the user while using the app. Blog link Detect Screenshots in Android Screen

A gallery application created by photographs taken by NASA's rover vehicle
A gallery application created by photographs taken by NASA's rover vehicle

Nasa-Gallery An Android application that uses the a Nasa API to display photos taken by the Mars Rover is built with MVVM pattern as well as Architect

androidx window manager sample taken from the original source and modified for easy deploy and test

androidx-window-samples This project contains the WindowManager samples located in the androidx WM project location The goal of this project is to pro

PopularMovieApp - A simple project to Chiper challenge taken data from The Movie DB based on Kotlin MVVM clean architecture
PopularMovieApp - A simple project to Chiper challenge taken data from The Movie DB based on Kotlin MVVM clean architecture

A simple project to Chiper challenge taken data from The Movie DB based on Kotli

Mobile development Exercise Simple photo viewer
Mobile development Exercise Simple photo viewer

Mobile development Simple Photo viewer Exercise A simple photo viewer based on Udacitys example app "dice roller"." Mobile development Exercise Simple

An android application that made as an exercise, that does 4 different conversions.

Following android studio basic course, this is my second (and bit more complicate this time) "practice on your own" project. In few words, it is an an

up-to-date version of codelab exercise TrackMySleepQuality-Starter

TrackMySleepQuality - Starter Code Starter code for Android Kotlin Fundamentals Codelab 6.1 Room Introduction TrackMySleepQuality is an app for record

Reach plc. Apps Team Exercise (Junior)

Reach plc. Apps Team Exercise (Junior) Description One of our magazines is looki

Weekly exercise-2-JamesYuRenxiang created by GitHub Classroom
Weekly exercise-2-JamesYuRenxiang created by GitHub Classroom

Weekly exercise-2-JamesYuRenxiang created by GitHub Classroom

Colored logcat script which only shows log entries for a specific application package.
Colored logcat script which only shows log entries for a specific application package.

PID Cat An update to Jeff Sharkey's excellent logcat color script which only shows log entries for processes from a specific application package. Duri

:package: Android Parcelables made easy through code generation.

Parceler Have a question? Ask it on StackOverflow. Found an issue? Please report it. In Android, Parcelables are a great way to serialize Java Objects

Owner
Luis Arcos
Luis Arcos
A lightweight game used to study activity lifecycle

DessertClicker - Code Code for Android Basics Codelab. Introduction DessertClicker is a game about making desserts. Press the button, make a dessert,

P 0 Dec 1, 2021
A simple project used for converting currencies

MyCurrencyConverter A simple project used for converting currencies. This project is divided into 2 parts (branches): master - without Dagger Hilt dev

null 0 Nov 5, 2021
This is the toy app for Lesson 9 of the Android App Development in Kotlin course on Udacity.

Behind the Scenes - DevByte Viewer App This is the toy app for Lesson 9 of the Android App Development in Kotlin course on Udacity. DevByte DevByte Vi

Jaime 1 Oct 20, 2021
The simple app is to demonstrate how the modern Enterprise Android App Architecture should be

Weather Forecast App The simple app is to demonstrate how the modern Enterprise Android App Architecture should be. Clean Architecture (Mr Uncle Bob)

null 2 Nov 12, 2021
eCommerce app developed with Android Jetpack and Kotlin

garden-shed eCommerce app developed with Android Jetpack and Kotlin This is my first mobile application. Garden Shed is a simple application for buyin

null 2 Nov 1, 2022
The code for the Congression App Challenge Webinar.

Getting-Started-with-Android-Studio-and-Kotlin-CAC-Webinar A webinar hosted by the Congressional App Challenge and theCoderSchool The code for the Con

null 1 Oct 18, 2021
LoadApp This is my submission for the "Building an Advanced Android App"

LoadApp This is my submission for the "Building an Advanced Android App" project of the Udacity Android Kotlin Developer nanodegree. (C) Jaldhar H. Vy

Jaldhar H. Vyas 1 Oct 7, 2021
An app to manage posts such as create, update, show the post list and detail also delete the post.

Otopost An app to manage posts such as create, update, show the post list and detail also delete the post. Minimum Requirements Software Android Studi

Imantoko 1 Oct 20, 2021
The source code for the Bus Scheduler app codelab

Bus Scheduler App This folder contains the source code for the Bus Scheduler app codelab. Introduction The Bus Scheduler app displays a list of bus st

Sharlene Kumbhar 1 Nov 21, 2021
Room - SleepQualityTracker app

Room - SleepQualityTracker app This is the toy app for Lesson 6 of the Android App Development in Kotlin course on Udacity. SleepQualityTracker The Sl

null 0 Jun 10, 2022